2
사용자 정의 listview 구현을 작성합니다. 이다 XML로 declaried 내보기의 예 : 'listSelector 안드로이드'자원이나 내 생성자에서 다른 속성보기 속성의 자원 ID를 얻으십시오.
<CustomListView android:id="@+id/list" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:listSelector="@drawable/listview_background">
</CustomListView>
이는 INT의의 가치를 얻을 수 있습니까?
public CustomListView(Context context, AttributeSet attrs) {
super(context, attrs);
this.listSelectorId = ???
}
나는이 함께 시도하지만 올바른 자원 ID를 반환하지 않습니다
public CustomListView(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.selectableItemBackground});
this.selectorResourceId = a.getResourceId(0, 0);
}
왜 android.R.attr.selectableItemBackground가 아니라 android.R.attr.listSelector? – njzk2
이 android.R.attr.listSelector로 변경되었습니다. – Richard
attr.getAttributeResourceValue ("android", "listSelector", -1)를 시도 했습니까? – njzk2