I am working on my android app and now i am in the process of creating app settings menu. I have created a menu but I want to display the menu at the top of the screen rather at the bottom so I am looking for some help.
Thanks in advance.
Ali
I am working on my android app and now i am in the process of creating app settings menu. I have created a menu but I want to display the menu at the top of the screen rather at the bottom so I am looking for some help.
Thanks in advance.
Ali
This is a tutorial for a quickAction Dialog, which you could use. - http://www.londatiga.net/it/how-to-create-quickaction-dialog-in-android/
To make a default android popup menu without any libraries use the following code.
On the foutrh line, the layout that you specify is your menu layout (see below)
public void showPopup(View v) {
PopupMenu popup = new PopupMenu(this, v);
MenuInflater inflater = popup.getMenuInflater();
inflater.inflate(R.layout.menu, popup.getMenu());
popup.show();
}
When you call this method, you need to do the following
View p = (View)findViewById(R.id.view);
showPopup(p);
In this price of code, View p
is the view at the location that you want to show the top corner of the menu. So if you happen to have a textview in the top corner, use that as the view to lodge your menu on.
For more info on this look here - android menu code not working To override the menu button function do the following
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ( keyCode == KeyEvent.KEYCODE_MENU ) {
//Put the code for an action menu from the top here
return true;
}
return super.onKeyDown(keyCode, event);
}