Android ListView mit alternativen Farbe und Fokus Farbe

Ich brauche, um alternativen Farbe in der Listendarstellung die Zeilen aber wenn ich das mache, dass es entfernt/deaktiviert den Fokus auf Standard-gelb hintergrund

Versuchte ich mit der Hintergrundfarbe
rowView.setBackgroundColor(FARBE);

auch mit backgrounddrwable.

rowView.setBackgroundColor(R.drawable.view_odd_row_bg);
<?xml version="1.0" encoding="utf-8"?>
<selector
   xmlns:android="http://schemas.android.com/apk/res/android">
   <item
      android:state_window_focused="false"
      android:drawable="@color/odd" />

   <!--
      Even though these two point to the same resource, have two states
      so the drawable will invalidate itself when coming out of pressed
      state.
   -->
   <item
      android:state_focused="true"
      android:state_enabled="false"
      android:state_pressed="true"
      android:drawable="@color/highlight" />
   <item
      android:state_focused="true"
      android:state_enabled="false"
      android:drawable="@color/highlight" />

   <item
      android:state_focused="true"
      android:state_pressed="true"
      android:drawable="@color/highlight" />
   <item
      android:state_focused="false"
      android:state_pressed="true"
      android:drawable="@color/highlight" />

   <item
      android:state_focused="true"
      android:drawable="@color/highlight" />

</selector>

aber es wird nicht funktionieren.

gibt es eine Möglichkeit, wir können die Hintergrundfarbe einstellen und auf Fokus Farbe gleichzeitig die Arbeit.

InformationsquelleAutor Yogesh | 2010-06-17

Schreibe einen Kommentar