Home » Android » Android: How to set a generated contextMenu title?

Android: How to set a generated contextMenu title?

Posted by: admin June 15, 2020 Leave a comment

Questions:

I create a context menu like this:

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
  if(v.getId() == R.id.ListView01) {
      getMenuInflater().inflate(R.menu.add_contextmenu, menu);
  }
  super.onCreateContextMenu(menu, v, menuInfo);
}

How can I now set a generated title?

How to&Answers:
menu.setHeaderTitle("This is my title");

See ContextMenu.setHeaderTitle