我正在使用 actionbarsherlock,我在菜单文件夹的 actionbar.xml 中声明了我的菜单。这是 actionbar.xml 的内容
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/abSearch" android:showAsAction="always" android:icon="@drawable/search_orange"></item>
</menu>
现在我尝试实现 onOptionsItemSelected ,这就是我所做的:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.abSearch:
Intent intent = new Intent(this, SearchRecipes.class);
startActivity(intent);
return true;
}
}
但问题是eclipse说abSearch无法解决。我多次尝试清理项目但无济于事。