I am using ExpandableListView lv . This is what I have. ExpandableListView lv = (ExpandableListView) findViewById (....); lv.setOnChildClickListener (new ExpandableListView.OnChildClickListener () {@Override public boolean onChildClick (ExpandableListView parent, View v, int gp, int cp, long id) {
Toast.makeText(MainActivity.this, "Clicked", Toast.LENGTH_SHORT).show(); //perform action return true; } }); lv.setOnCreateContextMenuListener(new OnCreateContextMenuListener() { @Override public void onCreateContextMenu(ContextMenu contextMenu, View v,ContextMenuInfo menuInfo) { ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo; customMenu.show(v); //do other stuff contextMenu=null; } });
When I click on the clild element for a long time, customMenu.show(v) is called, and when I turn off the finger, its OnClickListener . Similarly, with a long press and then release the finger on a group element, its ContextmenuListener is called, and then the group expands to show the children. Is this normal behavior? how can i prevent this?
I really want to do things on long Click in a list item. Returning true in longClickListener working correctly (expends the click event). But I also need to get the id, group and child position element, which is provided through ContextMenuInfo only in the context listener.
source share