title: Android  setting LinearLayout background programmatically
body: <p>I have a situation where I need to set a background on a LinearLayout programatically. </p>
  
  <p>In my layout, I am setting my background using `android:background="?android:attr/activatedBackgroundIndicator", but I want to set this programatically:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/myLayoutId"
      android:layout_width="wrap_content"
      android:layout_height="fill_parent"
      android:gravity="left|center"
      android:paddingBottom="5dip"
      android:paddingLeft="5dip"
      android:background="?android:attr/activatedBackgroundIndicator"
      android:paddingTop="5dip" &gt;
  </code></pre>
  
  <p>I've tried using: </p>
  
  <pre><code>Drawable d = getActivity().getResources().getDrawable(android.R.attr.activatedBackgroundIndicator);
  rootLayout.setBackgroundDrawable(d);
  </code></pre>
  
  <p>But it crashes. Any ideas?</p>
  
  <p>Edit: I had also tried using:</p>
  
  <pre><code>rootLayout.setBackgroundResource(android.R.attr.activatedBackgroundIndicator);
  
  10-08 15:23:19.018: E/AndroidRuntime(11133): android.content.res.Resources$NotFoundException: Resource ID #0x10102fd
  </code></pre>