userSeven7s mostly has it with the ListPopupWindow
, but an even better fit in this case is the PopupMenu
, which allows you to inflate a standard menu.xml
. You can place your own View
or Button
in the upper right and in the onClick
handler create and show a PopupMenu.
An example can be found in ApiDemos > Views > Popup Menu . Specifically PopupMenu1.java
:
public void onPopupButtonClick(View button) {
PopupMenu popup = new PopupMenu(this, button);
popup.getMenuInflater().inflate(R.menu.popup, popup.getMenu());
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem item) {
Toast.makeText(PopupMenu1.this, "Clicked popup menu item " + item.getTitle(),
Toast.LENGTH_SHORT).show();
return true;
}
});
popup.show();
}