Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom background for activatedBackgroundIndicator on ActionBarSherlock doesn't work
    primarykey
    data
    text
    <p>I'm using <strong>ActionBarSherlock</strong> and I'm trying to customize the <em>activatedBackgroundIndicator</em> attribute for the row background.</p> <p>If I use the latest android sdk, without the <strong>ActionBarSherlock</strong>, I'm able to customize the background creating the following style on <em>res/values/style.xml</em> and defining it on <em>AndroidManifest.xml</em> as <em>android:theme="@style/Theme.Custom"</em>: </p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;style name="Theme.Custom" parent="android:Theme.Holo.Light.DarkActionBar"&gt; &lt;item name="android:activatedBackgroundIndicator"&gt;@drawable/activated_background&lt;/item&gt; &lt;/style&gt; &lt;/resources&gt; </code></pre> <p>Then, my <em>res/drawable/activated_background.xml</em> contains the next code: </p> <pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:state_activated="true" android:drawable="@color/row_activated" /&gt; &lt;item android:drawable="@android:color/transparent" /&gt; &lt;/selector&gt; </code></pre> <p>Finally, the code used to define each row in the ListView is:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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"&gt; &lt;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"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>The result is shown on the screenshoot. Is a simple application with only a ListView with <strong>ListView.CHOICE_MODE_SINGLE</strong> and <strong>getListView().setItemChecked(position, true)</strong> when list item clicked. </p> <p>The blue color of the standard selected row now is yellow and works perfectly.</p> <p><img src="https://i.stack.imgur.com/mfwch.png" alt="List without ABS"></p> <p>The problem appears when I want to apply the same customization using the ActionBarSherlock. Now The style file is the next and the background appears blue instead the custom yellow.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;style name="Theme.Custom" parent="Theme.Sherlock.Light.DarkActionBar"&gt; &lt;item name="activatedBackgroundIndicator"&gt;@drawable/activated_background&lt;/item&gt; &lt;item name="android:activatedBackgroundIndicator"&gt;@drawable/activated_background&lt;/item&gt; &lt;/style&gt; &lt;style name="activatedBackgroundIndicator"&gt; &lt;item name="android:background"&gt;?android:attr/activatedBackgroundIndicator&lt;/item&gt; &lt;/style&gt; &lt;/resources&gt; </code></pre> <p><img src="https://i.stack.imgur.com/Q3P6x.png" alt="List with ABS"></p> <p>I don't know if <strong>ActionBarSherlock</strong> supports the <em>android:activatedBackgroundIndicator</em> feature or if I forgot to implement something needed to be able to change the default color.</p> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload