I am currently working on an Android project. I am using a ListView and using a context action bar and I am successfully selecting each item and showing a count of how many items have been selected within the list view.
Within the context bar I have a menu option for Select All
but I don't know how I can make sure that every item within the list view is selected.
I can't seem to find anything on Google, anything about this type of thing and selectable ListViews seem to be very well hidden.
If you only want to select what is on screen, then use listview. getChildCount() . If you are using fragments, you will need to use getListAdapter(). getCount() .
You can check listview items one by one:
for ( int i=0; i < listview.getAdapter().getCount(); i++) {
listview.setItemChecked(i, true);
}
If you only want to select what is on screen, then use listview.getChildCount()
.
If you are using fragments, you will need to use getListAdapter().getCount()
.
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