我有一个操作栏,将所有内容放在右上角的菜单中,用户点击后菜单选项会展开。
我会在每个使用它的活动中使用以下代码来填充操作栏菜单:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main2, menu);
return true;
}
而我的 main2.xml 的 XML 代码如下:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/action_searchHome"
android:orderInCategory="100"
android:showAsAction="never"
android:title="Seach"/>
</menu>
我的问题是,在XML中的项中我是否需要放置一个onclick,如果需要,调用该方法的onclick应该放在哪里?我需要在每个启动此操作栏的活动中都放置它吗?