2015-07-28 40 views
3

Menu picture如何與Android操作菜單文字顯示圖標的列表,如圖片

我想告訴像動作按鈕(3 ...圖標)的點擊圖像選項的彈出窗口。

我試圖通過選項菜單,但圖標不來。請建議我如何添加圖標。

<menu xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
tools:context="ui.dealroomcontent.DealRoomContentActivity"> 

<item 
    android:id="@+id/action_view_details" 
    android:title="View room details" 
    android:orderInCategory="100" 
    android:icon="@drawable/ic_dealroom_details_normal" 
    app:showAsAction="never" /> 

<item 
    android:id="@+id/action_add_file" 
    android:title="@string/action_create_file" 
    android:orderInCategory="100" 
    android:icon="@drawable/ic_dealroom_createfolder_normal" 
    app:showAsAction="never" /> 

<item 
    android:id="@+id/action_add_folder" 
    android:title="@string/action_create_folder" 
    android:icon="@drawable/ic_dealroom_createfile_normal" 
    android:orderInCategory="100" 
    app:showAsAction="never" /> 

<item 
    android:id="@+id/action_upload_from_camera" 
    android:title="@string/action_upload_from_camera" 
    android:icon="@drawable/ic_dealroom_uploadcamera_normal" 
    android:orderInCategory="100" 
    app:showAsAction="never" /> 

<item 
    android:id="@+id/action_upload_from_gallery" 
    android:title="@string/action_upload_from_gallery" 
    android:icon="@drawable/ic_dealroom_uploadgallery_normal" 
    android:orderInCategory="100" 
    app:showAsAction="never" /> 
<item 
    android:id="@+id/action_upload_from_local" 
    android:title="@string/action_upload_from_local" 
    android:orderInCategory="100" 
    android:icon="@drawable/ic_dealroom_upload_normal" 
    app:showAsAction="never" /> 

+0

嘗試在''內添加'app:showAsAction =「never | withText」'。它工作嗎? –

+0

檢查此:http://stackoverflow.com/questions/8908985/android-options-menu-icon-wont-display – SANAT

回答

10
<menu xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    tools:context=".MainActivity"> 

    <item 
     android:id="@+id/action_more" 
     android:icon="@drawable/ic_more_white" 
     android:title="@string/action_more" 
     android:orderInCategory="100" 
     app:showAsAction="always"> 
     <menu> 
      <item 
       android:id="@+id/action_settings" 
       android:icon="@drawable/ic_settings_black" 
       android:title="@string/action_settings" 
       android:orderInCategory="100" 
       app:showAsAction="never" /> 

      <item ... /> 
     </menu> 

    </item> 

</menu> 

的ic_more_white是3圖標... 我希望這可以幫助你。

相關問題