I just making some useful ListView with ListView.CHOICE_MODE_MULTIPLE mode and next "Select all", "Select none" and "Reverse selection" actions based on this example. I hung on select_all action here:
public void select_all(){
if( mListView == null ){ return; }
int len = mListView.getCount();
if( mListView.getChoiceMode() == ListView.CHOICE_MODE_MULTIPLE ) {
for (int i = 0; i < len; i++) {
mListView.setItemChecked(i, true);
}
}
}
Seems, I properly set up CHOICE_MODE_MULTIPLE:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mListView = (AbsListView) view.findViewById(android.R.id.list);
((AdapterView<ListAdapter>) mListView).setAdapter(mAdapter);
mListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
return view;
}
Manually, from touch screen I could select several items, but when I make select_all, iteration works, but just last item selected on the screen, all others checked off (behaviour looks like a radio buttons on iteration!).
Needs any advice, plz!
Aucun commentaire:
Enregistrer un commentaire