2012-02-20 88 views
0

我使用了actionbarsherlock,並在菜單文件夾中的actionbar.xml中聲明瞭我的菜單。這裏的actionbar.xml的android訪問菜單文件夾中的資源

<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; 

     } 
    } 

但問題是日食說abSearch不能得到解決。我嘗試多次清理這些項目,但無濟於事。

回答

1

替換:

android.R.id.abSearch 

有了:

R.id.abSearch 
+0

我可以發誓,我已經試過反正這..謝謝! – imin 2012-02-20 02:48:28

相關問題