ListView problème ligne selectionnée
Bonjour,
Dans mon application, j'utilise un ViewPagerIndicator qui est un FragmentActivity qui lui même utilise deux Fragments sur laquelle je switch entre les deux.
Sur l'un de ses deux Fragments, j'ai une ListView Personnalisé avec différent TextView dedans. Tout fonctionne normalement sauf que je n'arrive pas à mettre une autre couleur sur la ligne sélectionné.
Code de ma ListView dans le layout :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
<ListView
android:id="@+id/lvListe"
android:layout_width="fill_parent"
android:layout_height="fill_parentA"
android:listSelector="@color/transparent"
>
</ListView> |
Code de ma ligne personnalisé :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/list_selector"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout> |
Code de mon list_selector
Code:
1 2 3 4 5 6 7 8 9 10 11
|
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:state_focused="true"
android:drawable="#FF699999" />
<item android:state_pressed="true"
android:drawable="#FF333333" />
<item android:state_focused="true"
android:drawable="#FF666666" />
</selector> |
Même en appliquant c'est différentes couleur lorsque je clique ou reste focus dessus rien ne se passe.
Cordialement,
problème toujours présent...
Merci pour la réponse que tu as apporté mais le problème est toujours présent.
Mon nouveau row_selector :
Code:
1 2 3 4 5 6 7 8
|
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true" android:drawable="@color/GREEN" />
<item android:state_selected="true" android:drawable="@color/RED" />
<item android:drawable="@color/RED" />
</selector> |
Par défaut j'ai le couleur rouge et elle est bien présente. Lorsque je sélectionne ou presse ma liste view rien ne change...
Si vous auriez une idée de là ou ça peut venir.
Merci d'avance ;)
problème toujours présent...
Merci à toi de m'aidé mais ça ne fonctionne toujours pas...
Donc code de mon xml ou j'ai une list view
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/mainList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:listSelector="@android:color/transparent"
/>
</LinearLayout> |
code de ma ligne modifié
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/row_selector">
<CheckBox
android:id="@+id/checkBox_Sound"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
<TextView
android:id="@+id/tv_name_record"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="2012-13-05-22-14-10.mp3"
android:textSize="15dp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_duration_sound"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right"
android:gravity="right"
android:text="00:07" /> |
mon selector -> row selector
code fourni
Code:
1 2 3 4 5 6 7 8 9
|
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/RED" />
<item android:state_checked="true" android:drawable="@color/GREEN" />
<item android:state_selected="true" android:drawable="@color/abs__holo_blue_light" />
<item android:drawable="@color/abs__bright_foreground_holo_dark" />
</selector> |
A noter que j'effectue mes tests sur un Android 4.2.2 mais bon je pense pas que ça vienne de là dans des applications sur le market ça fonctionne nickel.
Si vous avez une idée de comment je pourrait le résoudre suis preneur.
Merci :cry::cry::cry::cry::cry::roll::roll::roll: