Is it possible to have both a context menu and default click behavior on ExpandableListView group items?
I tried this and found that once I overrode onCreateContextMenu in the activity that contained the ExpandableListView, the group views would no longer respond to clicks. They wouldn't highlight when (short) pressed and they wou开发者_JAVA技巧ldn't expand.
The solution is to let the Activity containing the ExandableListView know that it should handle context menu creation for the view. This can be accomplished as follows, most likely in the overridden onCreate
method of the Activity:
ExpandableListView listView = (ExpandableListView) findViewById( R.id.list );
registerForContextMenu( listView );
Then, in the Activity, be sure to override onCreateContextMenu
, where you'll configure the context menu that gets shown.
精彩评论