Closed drumonii closed 11 years ago
You need to set your onItemClick listener via the adapter, not via the ListView as you would normally do. See this sample.
Hope that helps. If not, please let me know.
I've followed that example along with the others and each of them has the onItemClick not within the selection mode. I put the onItemClick in the adapter as opposed to the activity and still it was triggered not within the selection mode. Still not sure what's going on.
Sorry but I'm not sure what the problem is or what you want to achieve. Can you please elaborate a bit? If you send me a little program that illustrates your problem it would help a lot, too.
On Fri, May 31, 2013 at 4:22 AM, dRock224 notifications@github.com wrote:
I've followed that example along with the others and each of them has the onItemClick not within the selection mode. I put the onItemClick in the adapter as opposed to the activity and still it was triggered not within the selection mode. Still not sure what's going on.
— Reply to this email directly or view it on GitHubhttps://github.com/ManuelPeinado/MultiChoiceAdapter/issues/8#issuecomment-18719994 .
Yeah sure. Basically I have a toolbar that needs to be expanded when the item is clicked. However I only want to capture the onItemClick when the MultiChoiceAdapter is in its selection mode, so its action mode is active.
private class MyAdapter extends MultiChoiceSimpleCursorAdapter {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
View toolbar = view.findViewById(R.id.toolbar);
ExpandAnimation animation = new ExpandAnimation(toolbar, ExpandAnimation.ANIMATION_DURATION);
toolbar.startAnimation(animation);
}
}
I do want to capture the click when the Adapter is in its selection mode. Similiar to
setItemClickInActionModePolicy(ItemClickInActionModePolicy.OPEN);
in this example but instead of exiting the action mode selection, the onItemClick should be used and the selection mode stay open.
Hi, thanks for the explanation. Now I understand what you need, but I'm reluctant to change the library to enable it because I don't know if a lot of people are gonna need this behavior besides you. For the time being you'll be better off forking the project and modifying the source code yourself. It's really simple, just comment out the call to "finishActionMode" in MultiChoiceAdapterHelper#onItemClick:
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
if (actionMode != null) {
switch (itemClickInActionModePolicy) {
case SELECT:
onItemLongClick(adapterView, view, position, id);
return;
case OPEN:
// finishActionMode();
break;
default:
throw new RuntimeException("Invalid \"itemClickInActionMode\" value: " + itemClickInActionModePolicy);
}
}
if (itemClickListener != null) {
itemClickListener.onItemClick(adapterView, view, position, id);
}
}
How can one get a checked itemClick during the selection mode? Like something similar to [onItemCheckedStateChanged](http://developer.android.com/reference/android/widget/AbsListView.MultiChoiceModeListener.html#onItemCheckedStateChanged(android.view.ActionMode, int, long, boolean). If I override [onItemClick](http://developer.android.com/reference/android/widget/AdapterView.OnItemClickListener.html#onItemClick(android.widget.AdapterView<?>, android.view.View, int, long), it is outside the multi choice selection mode.