vendredi 9 juin 2017

Check box inside a ListView, setChecked(true) is not working in Nougat

I have ListView of each item with text view and a check box

when clicking on each item I'm changing the check box state true/false to display selected items in a list.

 listSpinner.setOnItemClickListener(new AdapterView.OnItemClickListener() {
 @Override
 public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
    Helper.hideKeyBoard(getApplicationContext(), view);
    checkBox = (CheckBox) view.findViewById(R.id.chkbox_value);
    if (checkBox.isChecked()) {
       checkBox.setChecked(false);
       }
    else{
       checkBox.setChecked(true);                           
     }
     }

    });

I tried using runaable also :

 checkBox.post(new Runnable() {
                            @Override
                            public void run() {
                                checkBox.setChecked(true);
                            }
                        });

it is working on Marshmallow correctly but not working on Nougat!

Note : when I click on the second item the first item tick is showing in nougat.




Aucun commentaire:

Enregistrer un commentaire