android java开发中遇到的一个小程序段~
请教编程大神一下~下面这个小程序段是什么意思?实现了什么?最好能给每句加个简单的标注!谢谢各位程序员大哥!@OverridepublicbooleanonCreateOp...
请教编程大神一下~ 下面这个小程序段是什么意思?实现了什么?最好能给每句加个简单的标注!谢谢各位程序员大哥!
@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);
} 展开
@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);
} 展开
1个回答
展开全部
@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();//获取选中项目的id
if (id == R.id.action_settings) { //如果id为cation_settings
return true;//拦截
}
return super.onOptionsItemSelected(item);//否则按照父类的方式处理
}
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();//获取选中项目的id
if (id == R.id.action_settings) { //如果id为cation_settings
return true;//拦截
}
return super.onOptionsItemSelected(item);//否则按照父类的方式处理
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |