我使用的是自定義的操作欄,所以我必須創建一個XML文件namedthemes改成@繪製/菜單/的themes.xml我的代碼:自定義動作條列表視圖中選擇顏色
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="android:windowNoTitle">false</item>
<item name="android:windowFullscreen">true</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:background">#2d73c4</item>
</style>
</resources>
此外,我創建的.xml當我使用一個ListView,我選擇的項目要改變顏色
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/search"
android:showAsAction="always"
android:title="Αναζήτηση"
android:icon="@drawable/ic_action_search"/>
</menu>
所以我想:文件名動作條放入@繪製/菜單/ actionbar.xml我的代碼。 我在我的themes.xml中嘗試了這一行,但它沒有奏效。
<item name="android:colorActivatedHighlight">@android:color/transparent</item>
不能安靜地理解你的問題,你有一個列表視圖,當你選擇一個項目,你的操作欄應該改變它的顏色?哪種顏色?背景? –
完全正確。現在,當我選擇項目不會改變背景顏色。 – Dim
您是否在應用中添加了「工具欄」小部件?你可以通過id找到它,並在後面的代碼中設置它的背景顏色。 –