I have a list view with custom adapter, with an Image Button and a Text View.
I want to open a context menu when a press is made on the Image Button, and open another context menu if i press the Text View.
How can I do this??
This is my onClickListener
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (id == view.findViewById(R.id.label).getId()) //label press
{
TextView text = (TextView) view.findViewById(R.id.label);
registerForContextMenu(text);
openContextMenu(text);
}
else //imageButton press
{
ImageButton ib= (ImageButton) view.findViewById(R.id.image);
registerForContextMenu(ib);
openContextMenu(ib);
}
}
});
Add OnCreateContextMenuListener to the view:
In your activity view: