动作条微调用一个图标(如谷歌地图),我怎么能做到这一点? [英] ActionBar spinner with an icon (like Google Maps), how can I achieve that?
问题描述
我目前想,除了惊人的ActionBerSherlock库中添加一个微调导航菜单在我的应用程序(如谷歌地图)
I am currently trying, in addition of the amazing ActionBerSherlock library to add a spinner navigation menu in my application (like Google Maps)
注:我一直还想着Spotify的/ Evernote的/ Facebook的模式,但在Android上似乎不妥:的 http://alexanderblom.se/2012/04/23/android-navigation-and-spotify/
Note: I have been thinking also about the SPotify/Evernote/Facebook pattern, but that seems inappropriate on Android: http://alexanderblom.se/2012/04/23/android-navigation-and-spotify/
我已经制作了微调(http://developer.android.com/design/building-blocks/spinners.html),但添加一个图标看起来不那么容易。
I have already worked on the spinner (http://developer.android.com/design/building-blocks/spinners.html), but adding an icon seems not so easy
感谢了很多此菜...
Thank a lot for any link or help on this menu...
推荐答案
首先,你需要创建一个CustomArrayAdapter为您的微调。它应同时处理,字符串数组和可绘制的数组。在你的情况可能是第二个阵列的一小总结。
First you need to create a CustomArrayAdapter for your spinner. It should handle both, an array of Strings and an array of Drawables. In your case perhaps a second array for a little summary.
那么你就需要为项目的布局与ImageView的的图标和一个TextView文本(也许是一个用于汇总)。重写getView()和getDropDownView(),以填补递了资源布局(createFromResource()可能是一个方法来考虑)。
Then you'll need a layout for the item with the ImageView for the icon and a TextView for the text (and perhaps one for the summary). Override the getView() and the getDropDownView() to fill your layout with the resources handed in (createFromResource() might be a method to look into).
有关导航,所有你需要做的是建立在你的onCreate)的CustomArrayAdapter(与资源的阵列,调用MyActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST),并通过MyActionBar.setListNavigationCallbacks饲料导航与您的CustomArrayAdapter(名单,这一点)。
For the Navigation, all you need to do is to create the CustomArrayAdapter in your onCreate() with the arrays of resources, call MyActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST) and feed the Navigation with your CustomArrayAdapter via MyActionBar.setListNavigationCallbacks(list, this).
这篇关于动作条微调用一个图标(如谷歌地图),我怎么能做到这一点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!