Reputation: 6381
I use Fragment which extends Fragment implements MultiChoiceModeListener
.
And a class extends BaseAdapter
.
I can get the only position When I select the item from Gridview like the following code:
public void onItemCheckedStateChanged(ActionMode mode, int position,
long id, boolean checked) {
// TODO Auto-generated method stub
mActionText.setText(formatString(fileListView.getCheckedItemCount()));
SparseBooleanArray checkedItems = fileListView.getCheckedItemPositions();
Log.i(TAG, "fileListView.getCheckedItemPositions(); = " + checkedItems);
if (checkedItems != null) {
for (int i=0; i<checkedItems.size(); i++) {
if (checkedItems.valueAt(i)) {
String item = fileListView.getAdapter().getItem(
checkedItems.keyAt(i)).toString();
Log.i(TAG,item + " was selected");
}
}
}
mode.invalidate();
}
And the value is like the following log:
EG Player(21867): fileListView.getCheckedItemPositions(); = android.util.SparseBooleanArray@43625dc0
I/MJPEG Player(21867): tw.com.a_i_t.IPCamViewer.FileBrowser.Model.FileNode@43c4b7e8 was selected
What is the value of item mean ?
Does there has other method can get all the item that I have select from Gridview?
Thanks in advance.
Upvotes: 0
Views: 745
Reputation: 1287
GridView
element allows you to get the checked views like so, depending on what you need:
gridView.getCheckedItemIds();
gridView.getCheckedItemPositions();
Upvotes: 2