@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
//getMenuInflater().inflate(R.menu.main, menu);
setIconEnable(menu, true);
menu.add(0, MENU_ABOUT, 0, "關於").setIcon(android.R.drawable.ic_menu_info_details);
menu.add(0, MENU_Quit, 0, "離開").setIcon(android.R.drawable.ic_menu_close_clear_cancel);
return true;
}
private void setIconEnable(Menu menu, boolean enable)
{
try
{
Class<?> clazz = Class.forName("com.android.internal.view.menu.MenuBuilder");
Method m = clazz.getDeclaredMethod("setOptionalIconsVisible", boolean.class);
m.setAccessible(true);
m.invoke(menu, enable);
} catch (Exception e)
{
e.printStackTrace();
}
}
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
//getMenuInflater().inflate(R.menu.main, menu);
setIconEnable(menu, true);
menu.add(0, MENU_ABOUT, 0, "關於").setIcon(android.R.drawable.ic_menu_info_details);
menu.add(0, MENU_Quit, 0, "離開").setIcon(android.R.drawable.ic_menu_close_clear_cancel);
return true;
}
private void setIconEnable(Menu menu, boolean enable)
{
try
{
Class<?> clazz = Class.forName("com.android.internal.view.menu.MenuBuilder");
Method m = clazz.getDeclaredMethod("setOptionalIconsVisible", boolean.class);
m.setAccessible(true);
m.invoke(menu, enable);
} catch (Exception e)
{
e.printStackTrace();
}
}
沒有留言:
張貼留言