Skip to content Skip to sidebar Skip to footer

Preserve State Of Elements Inside Listview's Each Row

I have designed a listview by inflating each row using inflater and I have changed color of convertView's elements on their click events. But after scrolling the list the elements

Solution 1:

Well, you're saving both states (text and status) in arrays, so at least that part is good. Now you need to check the states[] in your getView() to set the correct look and feel of your buttons according to it, something like:

if (subStatus[position].equals("Ok")) {
            tvOk.setClickable(false);
            btnChecked.setClickable(true);
            btnAlert.setClickable(true);
            tvOk.setBackgroundColor(Color.GREEN);
            btnChecked.setBackgroundColor(Color.WHITE);
            btnAlert.setBackgroundColor(Color.WHITE);
            subStatus[position]="Ok";
          }
          ....

Then when you submit you can go through these status items and see what was clicked or not.

Post a Comment for "Preserve State Of Elements Inside Listview's Each Row"