我只是将我的应用程序升级到版本5.0。 我正在更新的代码相当老,而菜单显示在所有较低版本中。 究竟是什么问题,我似乎无法理解。该应用程序是一个没有操作栏的全屏。菜单选项不显示在android lollipop 5.0中?
在早期版本的菜单图标中,用于在底部显示主屏幕和后屏幕按钮的显示位置。
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
}
@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);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
你在哪里膨胀你的菜单布局应该在XML-res文件夹菜单重新安装Android文档?通常这应该在'onCreateOptionsMenu(菜单菜单)',这是创建活动后调用... – Mike 2014-12-02 11:16:23
菜单图标不显示在棒棒糖中。 – WISHY 2014-12-02 11:42:13