Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
455 views
in Technique[技术] by (71.8m points)

Displaying icon for menu items of Action Bar in Honeycomb android 3.0

hi
I am developing an android application using Honeycomb android 3.0 . I am tryig to display a menu in Action Bar . The menu has an icon and tiltle. When we click the menu item it displays its items in the form of a dropdown list .It was the items in drop down list with item names but with out icon it is displaying . I want an icon to be displayed beside the title in drop down list which appears when I click the menu. can anyone help me in sorting out this issue. my xml file is as below:

 <?xml version="1.0" encoding="utf-8"?>           
<menu  xmlns:android="http://schemas.android.com/apk/res/android">  
<item          
  android:id="@+id/addserver"  
  android:icon="@android:drawable/ic_menu_add"   
  android:title="Add Server"    
  android:showAsAction="ifRoom|withText"     
>  

<menu>    
            <item android:id="@+id/fileserver"    
                  android:icon="@android:drawable/ic_menu_add"  
                  android:title="File Server"          
                  android:onClick="onCreate"           
                  android:showAsAction="always"/>      
            <item android:id="@+id/sharepoint"            
                  android:icon="@android:drawable/ic_menu_add"  
                  android:title="Share Point"          
                  android:onClick="onCreate" />          
        </menu>            
</item>

Initially it displays add server with icon on left. clicking on that will display fileserver ,sharepoint as dropdown list with out icon though I given android:icon statement.
Can anyone help me in sorting out this issue?
Thanks in Advance,

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The behavior where icons are not displayed in the action bar's overflow menu is by design (as of this writing). If you absolutely need to use icons, you'll need to write a custom implementation consider rethinking your design to fit the UI conventions.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...