How to make this drop-down menu in the upper right corner. Does anyone have lessons on this topic?
in place toast.maketext (feedatory.this, "hello", toast.length_long) .show ();
, I want to realize what, wrote @katso
@ override
Public Boolean OnoPtionSetemSelected (MenuItem Item) {
int id = item.getitemid ();
Switch (ID) {
Case android.r.id.home:
mdrawerlayout.opendrawer (gravitycompat.start);
RETURN TRUE;
Case R.ID.Menu_Filter:
Toast.maketext (FeedActivity.this, "Hello", toast.length_long) .show ();
RETURN TRUE;
}
RETURN SUPER.ONOPTIONSIEMSELECTED (Item);
}
Answer 1, Authority 100%
popup_menu.xml
& lt; menu xmlns: android = "http://schemas.android.com/apk/res/android" & gt;
& lt; item
Android: id = "@ + id / one"
Android: title = "One" / & gt;
& lt; item
Android: id = "@ + id / two"
Android: title = "two" / & gt;
& lt; item
Android: id = "@ + id / three"
Android: title = "three" / & gt;
& lt; / menu & gt;
button button = (button) findviewbyid (r.id.button);
Button.SetonClicklistener (new onclicklistener () {
@Override
Public Void OnClick (View V) {
PopupMenu Popup = New PopupMenu (MainActivity.this, Button);
popup.getmenuinflater (). Inflate (R.Menu.popup_Menu, popup.getMenu ());
popup.setonmenuitemclicklistener (new popupmenu.onmenuitemclicklistener () {
Public Boolean OnMenuitemClick (MenuItem Item) {
Toast.maketext (MainActivity.this, "You Clicked:" + Item.Gettitle (), toast.length_short) .show ();
RETURN TRUE;
}
});
popup.show ();
}
});