如何通过单击physical menuKey扩展ActionBar菜单?

时间:2015-02-03 12:09:19

标签: android

所以这是xml文件结构:sfsafsadfsdfasdfasdfasdfasdfsdfsd

 <item...>
    <menu>
       <item>
       </item>
       <item>
       </item>
       <item>
       </item>
   </menu>
  </item>

1 个答案:

答案 0 :(得分:0)

试试这个..

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.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();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        //do your stuff here..
        return true;
    } 
    return super.onOptionsItemSelected(item);
}