朋友们,我想在Android键盘上按下默认菜单按钮时,从屏幕底部弹出一个按钮。我想从那个弹出按钮导航到其他屏幕。
答案 0 :(得分:0)
首先必须在/menu/menu.xml中声明所需的菜单 然后你的菜单需要一个inflater:
// menuinflater
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
处理你的菜单:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// only one menu option here for preferences
// for more just add new case with your ids
case R.id.firstmenuitem:
// Launch preferences activity
Intent i = new Intent(youractivity.this, preferences.class);
startActivity(i);
break;
}
return true;
}
问候