I've a ListActivity
public class MyActivity extends ListActivity{
protected void onCreate(Bundle savedstate){
super.onCreate(savedstate);
getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
getListView().setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
Log.i("xxx", "onPrepareActionMode");
return false;
}
public void onDestroyActionMode(ActionMode mode) {
// TODO Auto-generated method stub
}
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
// TODO Auto-generated method stub
return true;
}
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
// TODO Auto-generated method stub
return false;
}
public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
Log.i("xxx", "pos: "+position+", checked: "+checked);
mode.setTitle(getListView().getCheckedItemCount()+" checked");
}
});
}
}
Here I can see the items getting checked but background of checked items is not changing. I know a way how to do it, have your CustomAdapter
and in getView()
set the background of the views that are checked. But I believe there is much simpler way to handle it. Could you tell me if there is anyway to achieve it?
Attaching the Screenshot
Ok, i got the answer by going through the source code of other app which does that. Set a statelist drawable as background for list item. In selector state_activated = true
give the background drawable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With