У меня есть linearlayout и как показано ниже в коде1, я добавляю к нему фон для изменения его внешнего вида/фона при его выборе.Как добавить селектор к виду программно
в Кодекса2 ниже, я надуть вид и я хочу, чтобы добавить один и тот же селектор/фон «андроид: фон =„Android: атр/listChoiceBackgroundIndicator“» к представлению завышены в Кодекса2
как я могу делать это программно?
code1:
<LinearLayout
android:id="@+id/versicherungs_verDetailsListFooter_container"
android:layout_width="match_parent"
android:layout_height="@dimen/vers_height"
android:layout_below="@id/horizontalDivider0"
android:clickable="true"
android:orientation="horizontal"
android:paddingLeft="15dp"
android:visibility="gone"
android:weightSum="1"
android:background="?android:attr/listChoiceBackgroundIndicator">
code2:
final LinearLayout linLay = (LinearLayout) findViewById(R.id.versicherungs_verDetailsListFooter_container);
LayoutInflater inflator = this.getLayoutInflater();
final View view = inflator.inflate(R.layout.versicherungs_docs_footer, null);
RelativeLayout relLay = (RelativeLayout) view.findViewById(R.id.versicherungs_footer_mainContainer);
final TextView texVieShowMore = (TextView) view.findViewById(R.id.showMore);
final TextView texVieShowLess = (TextView) view.findViewById(R.id.showLess);
final TextView texVieShowMoreArrow = (TextView) view.findViewById(R.id.showMoreArrow);
final TextView texVieShowLessArrow = (TextView) view.findViewById(R.id.showLessArrow);
//how to add the selector "?android:attr/listChoiceBackgroundIndicator" to the RelativeLayout "relLay"
я думаю, что 'Тема # resolveAttribute' будет делать трюк получать' resourceId' – pskink
@pskink бы у пожалуйста, приведите пример – user2121
я не имею никакого – pskink