Android definindo o plano de fundo do LinearLayout programaticamente

Eu tenho uma situação onde eu preciso definir um plano de fundo em um LinearLayout programaticamente.

No meu layout, estou definindo meu plano de fundo usando android: "background:" android: attr / activatedBackgroundIndicator ", mas eu quero definir isso programaticamente:

<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" >

Eu tentei usar:

Drawable d = getActivity().getResources().getDrawable(android.R.attr.activatedBackgroundIndicator);
rootLayout.setBackgroundDrawable(d);

Mas isso falha. Alguma ideia?

Edit: Eu também tentei usar:

rootLayout.setBackgroundResource(android.R.attr.activatedBackgroundIndicator);

10-08 15:23:19.018: E/AndroidRuntime(11133): android.content.res.Resources$NotFoundException: Resource ID #0x10102fd

questionAnswers(6)

yourAnswerToTheQuestion