For a ContextMenu
, make sure you are long pressing on the image button. Otherwise, a simple tap on the button will not have the context menu shown.
From the documentation of ContextMenu:
To show a context menu on long click, most clients will want to call registerForContextMenu(View) and override onCreateContextMenu(ContextMenu, View, ContextMenu.ContextMenuInfo).
If you want the context menu to be shown on a single click, you can manually show it:
btn_settings = (ImageButton) findViewById(R.id.btn_settings);
registerForContextMenu(btn_settings);
btn_settings.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
view.showContextMenu();
}
});