In the activity, overwrite the following two methods:
Copy Code code as follows:
Create a Menu
@Override
public boolean
oncreateoptionsmenu(Menu menu) {
Menu.add (0, 0, 0, "about");
Menu.add (int groupId, int itemId, int order, charsequence title)
Menu.add (0, 1, 1, "exit");
return Super.oncreateoptionsmenu (menu);
}
Menu response
@Override
public boolean onoptionsitemselected(MenuItem item) {
super.onoptionsitemselected (item);
Switch (Item.getitemid ()) {
Case 0:
Toast.maketext (Getapplicationcontext (), "blog About Livingstone", 1). Show ();
Break
Case 1:
This.finish ();
Break
}
return true;
}
**************************************************************************************************
Get Phone resolution Size
Copy Code code as follows:
Private
displaymetrics dm = new Displaymetrics ();
Getwindowmanager (). Getdefaultdisplay (). Getmetrics (DM);
Get cell phone broadband and height pixel units for px
String str = "Mobile screen resolution:" + Dm.widthpixels + "*" +dm.heightpixels;