所以我想要实现的是, *** 作栏内的项目文本颜色是白色,而菜单d出的项目文本颜色是黑色.
这是我到目前为止的两个例子:
它应该是这样的:
有谁知道解决方案?
这是我的列表导航代码:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,androID.R.layout.simple_dropdown_item_1line,new String[] { "Item 1","Item 2" });getSupportActionbar().setNavigationMode(Actionbar.NAVIGATION_MODE_List);getSupportActionbar().setListNavigationCallbacks(adapter,new Actionbar.OnNavigationListener() { @OverrIDe public boolean onNavigationItemSelected(int itemposition,long itemID) { return true; } });getSupportActionbar().setSelectednavigationItem(0)
这些是我使用的样式集合.
<style name="Customtheme" parent="@style/theme.customized"> <item name="actionbarStyle">@style/Widget.Styled.Actionbar</item> <item name="androID:actionbarStyle">@style/Widget.Styled.Actionbar</item> <item name="actionDropDownStyle">@style/CustomSherlockDropDownNav</item> <item name="androID:actionDropDownStyle">@style/CustomSherlockDropDownNav</item> <!-- dIDn't work: https://stackoverflow.com/questions/12395381/androID-actionbar-navigation-spinner-text-color <item name="androID:spinnerDropDownItemStyle">@style/custom.Widget.DropDownItem.Spinner</item> <item name="spinnerDropDownItemStyle">@style/custom.Widget.DropDownItem.Spinner</item> --> <!-- dIDn't work: https://stackoverflow.com/questions/11479186/styling-actionbar-dropdown-menu <item name="androID:actionbarWidgettheme">@style/custom.actionbarWidgettheme</item> <item name="actionbarWidgettheme">@style/custom.actionbarWidgettheme</item> --> <!-- dIDn't work: http://androID-developers.blogspot.de/2011/04/customizing-action-bar.@R_502_6832@ <item name="androID:dropdownlistviewStyle">@style/Customdropdownlistview</item> <item name="dropdownlistviewStyle">@style/Customdropdownlistview</item> --> .... </style><style name="custom.actionbarWidgettheme" parent="@style/theme.Sherlock.light.DarkActionbar"> <item name="androID:spinnerDropDownItemStyle">@style/custom.Widget.DropDownItem.Spinner</item></style><style name="custom.Widget.DropDownItem.Spinner" parent="@style/Widget.Sherlock.DropDownItem.Spinner"> <item name="androID:textAppearance">@style/custom.TextAppearance.Widget.DropDownItem</item></style><style name="custom.TextAppearance.Widget.DropDownItem" parent="@style/TextAppearance.Sherlock.Widget.DropDownItem"> <item name="androID:textcolor">#00A000</item></style><style name="Customdropdownlistview" parent="androID:style/Widget.Holo.ListVIEw.DropDown"> <item name="androID:textcolor">#00A000</item> <item name="androID:textSize">8dip</item></style><style name="CustomSherlockDropDownNav" parent="@style/Widget.Sherlock.light.Spinner.DropDown.Actionbar"> <item name="androID:popupBackground">@drawable/menu_dropdown_panel_customtab</item> <item name="androID:background">@drawable/spinner_background_ab_customtab</item></style>
然而,没有什么不起作用.
解决方法 问题是您使用相同的资源androID.R.layout.simple_dropdown_item_1line作为微调器项和微调器下拉项.请改用R.layout.sherlock_spinner_item和R.layout.sherlock_spinner_dropdown_item.
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.sherlock_spinner_item,"Item 2" });adapter.setDropDownVIEwResource(R.layout.sherlock_spinner_dropdown_item);
这样,像Widget.Sherlock.TextVIEw.SpinnerItem这样的样式就可以了.
总结以上是内存溢出为你收集整理的android – ActionBar列表导航:标题和d出菜单中的不同文本颜色全部内容,希望文章能够帮你解决android – ActionBar列表导航:标题和d出菜单中的不同文本颜色所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)