I've a screen with a button that is placed somewhere on the screen (near the top).
I would like to click on the button and get this result: A menu is opened right below the button and lets you choose text(from the list) or write my own text(where "type here.." is written).
I've this popup menu:
PopupMenu popupMenu = new PopupMenu(this, buttonChooseText);
for (int i = 0; i < listDefaultText.size(); ++i) {
// the list is from String type and contains "text1" and so on
popupMenu.getMenu().add(listDefaultText.get(i);
}
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getTitle().toString()) {
case "Text1" :
//execute "text1" action
break;
case "Text2" :
//execute "text2" action
break;
}
return false;
}
});
popupMenu.show();
So how can I get this result?