2011-12-25 28 views
0

我將自己佈局的背景顏色,爲白色。列表視圖不可聚焦。如果我做了背景顏色爲白色

然後我通過擴展BaseAdapter類創建列表。 但我的列表項不可作爲焦點(當我將光標移動到它不顯示焦點顏色的任何項目)。

,但如果我刪除佈局的背景顏色標籤,它的工作原理是fine.below我的XML佈局。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" android:background="@color/color_white"> 

     <ImageView 
     android:id="@+id/icon" 
     android:layout_width="60dp" 
     android:layout_height="wrap_content" 
     android:visibility="visible" /> 

    <TextView 
     android:id="@+id/label" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10px" 
     android:textColor="@color/color_white" 
     android:textSize="20dp" 
     android:visibility="visible" /> 
</LinearLayout> 

請大家幫忙。

回答

0

列表項背景是"State List Drawables",它定義爲一個視圖的不同狀態的顏色。如果您將背景設置爲簡單的顏色,則在所有情況下都是該顏色。您只需要覆蓋特定的「狀態」中的默認繪製,以保持顏色的其餘部分完好。這是一個example

相關問題