Programowe ustawienie systemu Android na tle LinearLayout

Mam sytuację, w której programowo muszę ustawić tło na LinearLayout.

W moim układzie ustawiam tło za pomocą `android: background ="? Android: attr / activatedBackgroundIndicator ", ale chcę to ustawić programowo:

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

Próbowałem użyć:

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

Ale to się załamuje. Jakieś pomysły?

Edytuj: Próbowałem również użyć:

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