2013-05-29 4 views
0

ListView 항목에 문제가 있습니다. 나는 그것을 위해 listSelector를 사용하고있다. 누를 때 항목 변경 배경이 필요합니다. 그러나 그것을 누를 때 모든 항목이 배경을 바꿉니다. Android 2.3.6에서 발생합니다. 4.0.3 이상에서는 잘 작동합니다.ListView 항목 배경 문제

ListSelector

<selector xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/defaultSelector"> 
<item android:drawable="@color/defaultDashboardItemBackground" android:state_enabled="false" android:state_focused="true" android:state_pressed="false"/> 
<item android:drawable="@color/defaultDashboardItemHover" android:state_pressed="true"/> 
<item android:drawable="@color/defaultDashboardItemBackground" android:state_focused="true" android:state_pressed="false"/> 

이 그것을 수정하는 데 도움을 줄 수 있습니다 귀하의 목록보기 android:cacheColorHint="@null" 이 속성을 설정하는 코드

ListView list = (ListView) act.findViewById(R.id.menu_listview); 
list.setBackgroundColor(act.getResources().getColor(getThemeBackground(theme))); 
list.setSelector(act.getResources().getDrawable(getThemeSelector(theme))); 
list.addHeaderView(createHeader("HEADER")); 
list.setAdapter(adap); 

답변

0

.

+0

고마워요,하지만 작동하지 않습니다 : ( – asmproger

0
<ListView 
    android:id="@android:id/list" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:cacheColorHint="#00000000" 
    android:listSelector="#00000000" 
    android:fadingEdge="none"/> 

그리고 ListView에서 배경색을 정의하지 마십시오. listitem.xml 루트 레이아웃에서 배경색 (선택기) 또는 이미지 (선택기)를 정의하십시오.

희망이 도움이 될 것입니다.

+0

고마워,하지만 작동하지 않는다 :( – asmproger