2016-04-28 49 views
1

我無法使用自定義圖標而不是標準3點菜單圖標。以下是我有:Android自定義菜單圖標不顯示

menu_editor.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemes.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    tools:context="com.sunnyvalleystudio.notetakingapp.EditorActivity" 
    > 
    <item 
     android:id="@+id/action_delete" 
     android:icon="@drawable/ic_action_delete" 
     android:title="@string/action_delete" 
     android:orderInCategory="100" 
     app:showAsAction="always" 
     /> 
    <!--to show it in menu we need to change "never" to "always --> 
</menu> 

EditorActivity.java

@Override 
    public boolean onCreateOptionsMenu(Menu menu){ 
     //inflate the menus - adds items to the action bar menu if it is present 
     //MenuInflater gets the menu items from an existing XML file 

     //to display delete icon only in the existing notes 
     if (action.equals(Intent.ACTION_EDIT)){ 
      MenuInflater inflater = getMenuInflater(); 
      inflater.inflate(R.menu.menu_editor, menu); 

     } 
     return true; 
    } 

儘管這樣我仍然得到3點在其列表中的 「刪除」 位置圖標。爲什麼不顯示ic_action_delete圖標?它在資產中。我正在使用Nexus 5 API 19仿真器。

+0

它具體是什麼文件夾?這個圖標是什麼格式? – RScottCarson

回答

0

嘗試在inflate()方法中的「R.menu.menu_editor」之前添加包名(com.sunnyvalleystudio.notetakingapp。)並返回super.onCreateOptionsMenu(menu);