vendredi 29 avril 2016

Android: Dynamically show all checkboxes in adapter onLongClick

I was learning custom adapter concepts recently.

Problem is during onlongClick in a row, I want to show checkboxes checked in the longclicked row, which is in android:visibility="gone" initially. And also to show checkboxes in other rows which are not clicked in unchecked state.

I changed some parts of this code here. http://ift.tt/1TauxU1

In simplerow.xml I made android:visibility="gone" initially.

Now I made a onLongClickListener inside getView(...) method

textView.setOnLongClickListener (new View.OnLongClickListener() {
     @Override
     public boolean onLongClick(View v) {
         CheckBox cb = (CheckBox) v;
         Planet planet = (Planet) cb.getTag();  
         planet.setVisibility(View.VISIBLE);
         planet.setChecked(true);
     }
});

Now the above code will affect only the longClicked row. How do I make changes in the non-clicked rows?

Calling notifyDataSetChanged() on long click did not work because the other rows have checkbox initially in android:visibility="gone".

Please help. Is any other work around possible?




Aucun commentaire:

Enregistrer un commentaire