title: ListView items aren't displaying as activated
body: <p>So, everything is working great on smartphones. However, on tablets, my <code>ListView</code> is meant to be displayed as a left navigation element, with the currently activated item appearing expanded in the detail fragment. And that works great too. However, the <code>ListFragment</code>'s activated item doesn't display as selected. I've set <code>android:choiceMode</code> to <code>singleChoice</code>. I've got the right selector active, and the background drawable appears when an item is pressed. The selector has the right item for <code>android:state_activated="true"</code>. I'm specifying <code>android:activatedBackgroundIndicator</code> in my <strong>styles.xml</strong> file. When I log the output of <code>listView.getCheckedItemCount()</code> inside of <code>onListItemClick</code> it gives me back <code>1</code> as I'd expect.</p>
  
  <p>Once upon a time, a few weeks ago, I even had this all working exactly as intended with an <code>ArrayAdapter</code>, before I started wiring up my data source for real, and before I started using a custom list view item layout. And then somewhere along the way I did something that made activated items show up incorrectly, but I'm not sure what it was.</p>
  
  <p><strong>selectable_background.xml</strong></p>
  
  <pre><code>&lt;selector xmlns:android="http://schemas.android.com/apk/res/android"
          android:exitFadeDuration="@android:integer/config_mediumAnimTime" &gt;
      &lt;item android:state_pressed="false" android:state_focused="true" android:drawable="@drawable/list_focused" /&gt;
      &lt;item android:state_pressed="true" android:drawable="@drawable/pressed_background" /&gt;
  
      &lt;!-- selected --&gt;
      &lt;item android:state_activated="true" android:drawable="@drawable/pressed_background" /&gt;
      &lt;item android:state_checked="true" android:drawable="@drawable/pressed_background" /&gt; &lt;!-- paranoia --&gt;
      &lt;item android:state_selected="true" android:drawable="@drawable/pressed_background" /&gt; &lt;!-- paranoia --&gt;
  
      &lt;!-- default --&gt;
      &lt;item android:drawable="@android:color/transparent" /&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p><strong>fragment_list.xml</strong></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="match_parent"
    android:layout_height="match_parent" &gt;
  
      &lt;ListView xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@id/android:list"
          android:layout_width="match_parent"
          android:layout_height="0dip"
          android:layout_weight="1"
          android:choiceMode="singleChoice"
          android:listSelector="@drawable/selectable_background" &gt;
      &lt;/ListView&gt;
      &lt;TextView android:id="@id/android:empty"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:paddingTop="16dp"
          android:paddingBottom="16dp"
          android:paddingLeft="12dp"
          android:paddingRight="12dp"
          android:text="@string/empty_list" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>list_item.xml</strong></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="horizontal"
      android:layout_width="match_parent"
      android:layout_height="wrap_content" &gt;
  
      &lt;ImageView android:id="@+id/item_image"
          android:layout_width="63dp"
          android:layout_height="63dp"
          android:contentDescription="@string/list_image"
          android:src="@drawable/ic_thumbnail_placeholder"
          android:background="#f0f0f0" /&gt;
  
      &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/item_name"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:textAppearance="?android:attr/textAppearanceListItemSmall"
          android:gravity="center_vertical"
          android:paddingLeft="?android:attr/listPreferredItemPaddingLeft"
          android:paddingRight="?android:attr/listPreferredItemPaddingRight"
          android:minHeight="?android:attr/listPreferredItemHeightSmall" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>MyListFragment.java</strong></p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      this.getActivity().getLoaderManager().initLoader(ALL_ITEMS_LOADER, null, this);
      listAdapter = new SimpleCursorAdapter(
              this.getActivity(),
              R.layout.list_item,
              null,
              new String[] { Item.NAME },
              new int[] { R.id.item_name },
              CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER
      );
      this.setListAdapter(listAdapter);
  }
  
  @Override
  public Loader&lt;Cursor&gt; onCreateLoader(int i, Bundle bundle) {
      Uri queryUri;
      switch (i) {
          case ALL_ITEMS_LOADER:
              queryUri = Item.CONTENT_URI;
              return new CursorLoader(this.getActivity(), queryUri, null, null, null, null);
          default:
              throw new IllegalArgumentException("Unknown loader ID: " + i);
      }
  }
  
  @Override
  public void onLoadFinished(Loader&lt;Cursor&gt; cursorLoader, Cursor cursor) {
      if (listAdapter == null) {
          throw new IllegalStateException("List adapter is missing!");
      } else {
          Log.d(TAG, "Load finished. Cursor swapped.");
          listAdapter.swapCursor(cursor);
      }
  }
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>I also tried replacing the <code>SimpleCursorAdapter</code> with the <code>ArrayAdapter</code> that I had working before, but no dice:</p>
  
  <pre><code>listAdapter = new ArrayAdapter&lt;String&gt;(
          this.getActivity(),
          R.layout.list_item,
          R.id.item_name,
          new String[] {"1", "2", "3"}
  );
  </code></pre>
  
  <p><strong>Update 2:</strong></p>
  
  <p>Ahah! A clue!</p>
  
  <pre><code>listAdapter = new ArrayAdapter&lt;String&gt;(
          this.getActivity(),
          android.R.layout.simple_list_item_activated_1,
          android.R.id.text1,
          new String[] {"1", "2", "3"}
  );
  </code></pre>
  
  <p>This works. But since I actually need to use my own layout, it doesn't solve my own question. What's so different between <code>R.layout.list_item</code> and <code>android.R.layout.simple_list_item_activated_1</code>?</p>