Я использую ActionBarSherlock, и я пытаюсь настроить атрибут activeBackgroundIndicator для фона строки.
Если я использую последний sdk для Android, без ActionBarSherlock, я могу настроить фон, создав следующий стиль по res/values /style.xml и определяя его на AndroidManifest.xml как android: theme = "@style/Theme.Custom":
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Custom" parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:activatedBackgroundIndicator">@drawable/activated_background</item>
</style>
</resources>
Затем мой res/drawable/activated_background.xml содержит следующий код:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_activated="true" android:drawable="@color/row_activated" />
<item android:drawable="@android:color/transparent" />
</selector>
Наконец, код, используемый для определения каждой строки в ListView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?android:attr/activatedBackgroundIndicator">
<TextView
android:id="@+id/test_row"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/sample_string"
android:textAppearance="?android:attr/textAppearanceMedium"
android:padding="15dp"/>
</LinearLayout>
Результат показан на скриншоте. Является простым приложением только с ListView с ListView.CHOICE_MODE_SINGLE и getListView(). SetItemChecked (позиция, true) при нажатии на элемент списка.
Синий цвет стандартного выделенного ряда теперь желтый и отлично работает.
Проблема возникает, когда я хочу применить ту же настройку с помощью ActionBarSherlock. Теперь файл стиля является следующим, а фон становится синим вместо обычного желтого.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Custom" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="activatedBackgroundIndicator">@drawable/activated_background</item>
<item name="android:activatedBackgroundIndicator">@drawable/activated_background</item>
</style>
<style name="activatedBackgroundIndicator">
<item name="android:background">?android:attr/activatedBackgroundIndicator</item>
</style>
</resources>
Я не знаю, поддерживает ли ActionBarSherlock функцию android: activatedBackgroundIndicator, или я забыл реализовать что-то, что необходимо для изменения цвета по умолчанию.
Любые идеи?