android actionbar的option menu
在Activity加入下面這兩個方法
並且在res裡面新增menu資源檔
就可以使用
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean onCreateOptionsMenu(Menu menu) { | |
getMenuInflater().inflate(R.menu.menu_content,menu); | |
return super.onCreateOptionsMenu(menu); | |
} | |
@Override | |
public boolean onOptionsItemSelected(MenuItem item) { | |
if(item.getItemId()==R.id.action_upload){ | |
Log.d(TAG, "onOptionsItemSelected: "); | |
} | |
return super.onOptionsItemSelected(item); | |
} |
留言
張貼留言