Let's say for vocSpinner value = "Combat/Service" and popSpinner value = "NSmen" and I check cb1. It will give a list. However, when I change popSpinner to "Regular/NSF" it will change to another list (which is correct) but how do I uncheck the checkbox as well without creating another data that overlay. The codes I provided doesn't seem to work and I can't work it out. All help are welcome, thanks in advance!
imgur.com/a/1wt4N [Screenshot of app]
private String[] vocSpinner;
private String[] popSpinner;
private List<Standard> standardList = new ArrayList<>();
private RecyclerView recyclerView;
private StandardsAdapter sAdapter;
private CheckBox cb1;
private CheckBox cb2;
cb1 = (CheckBox) getActivity().findViewById(R.id.pushUp);
cb2 = (CheckBox) getActivity().findViewById(R.id.sitUp);
this.vocSpinner = new String[]{
"CDO/Diver/Gds/Fitness Spec", "Combat/Service"
};
this.popSpinner = new String[]{
"NSmen", "Regular/NSF", "Pre-enlistee"
};
final Spinner v = (Spinner) getActivity().findViewById(R.id.spinner_Voc);
final Spinner p = (Spinner) getActivity().findViewById(R.id.spinner_PopGp);
ArrayAdapter<String> adapterV = new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_spinner_item, vocSpinner);
v.setAdapter(adapterV);
ArrayAdapter<String> adapterP = new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_spinner_item, popSpinner);
p.setAdapter(adapterP);
v.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
standardList.clear();
cb1.setEnabled(true);
cb2.setEnabled(true);
switch (position) {
case 0:
if (p.getSelectedItem().equals("NSmen")) {
cb1.setChecked(false);
cb2.setChecked(false);
addStandardToList("Gold - $500", ">89pts");
addStandardToList("Silver - $300", ">74pts");
addStandardToList("Incentive - $200", ">60pts");
addStandardToList("Pass", ">50pts");
sAdapter.notifyDataSetChanged();
Aucun commentaire:
Enregistrer un commentaire