作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
您好,我正在使用 ActionBarSherlock 和 Navigation Drawer 开发一个应用程序。我创建了一个带有 actionBar Sherlock 的初始抽屉导航,就像这样:
一切似乎都很好但我想用我的自定义颜色更改突出显示的列表项的默认蓝色。我试过 this link但它不工作。我需要做什么才能实现自定义突出显示颜色?
最佳答案
您好,我已经通过应用样式解决了 Android 操作系统版本 11 及更高版本的问题:
<style name="AppBaseTheme" parent="Theme.Sherlock.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:activatedBackgroundIndicator">@drawable/activated_background</item>
</style>
drawable文件夹中的activated_background:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:drawable="@color/uva_color" />
<item android:state_selected="true" android:drawable="@color/uva_color" />
<item android:state_pressed="true" android:drawable="@color/uva_color" />
<item android:drawable="@color/default_color" />
</selector>
值文件夹中的颜色值:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="uva_color">#c31756</color>
<color name="default_color">#111</color>
</resources>
并在 ListView 中设置选择模式:
android:choiceMode="singleChoice"
最后,将 getBaseContext()
作为参数而不是 getApplicationContext()
发送到 arrayApdater/您的自定义适配器。
mMenuAdapter = new MenuListAdapter(this.getBaseContext(), title, icon);
还有 this link会帮助你。
如果您在任何地方遇到问题,请在下方发表评论。我随时准备回答,我不想让任何人像我一样遇到麻烦。干杯!
关于android - 如何在 activatedBackgroundIndicator 中的选定/突出显示的列表项上设置自定义颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17623961/
有没有一种方法可以“标记”对象的属性,使它们在反射中“突出”? 例如: class A { int aa, b; string s1, s2; public int AA
我是一名优秀的程序员,十分优秀!