j'ai un problème pour l’utilisation. voilà le contenu de mon listView
j'ai rempli les listview et tout va bien. le problème est situé au niveau de textview titrethemet que je veux son couleur background apparait selon son contenut çad background variable.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 <?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="150px" android:background="@drawable/re02" > <TextView android:id="@+id/titrethemet" android:layout_width="fill_parent" android:layout_height="30px" android:textSize="16px" android:textStyle="bold" android:background="#257FBD" android:text="Business" /> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="120px" > <ImageView android:layout_height="120px" android:layout_width="120px" android:id="@+id/imgt" android:padding="10px"></ImageView> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="120px" android:layout_height="120px" > <TextView android:id="@+id/descriptiont" android:layout_width="fill_parent" android:layout_height="80px" /> <TextView android:id="@+id/descriptiont" android:layout_width="fill_parent" android:layout_height="40px" android:text="Voir tous les produits>" android:textSize="11px" android:textColor="#E8D20A" /> </LinearLayout> </LinearLayout> </LinearLayout>
Aussi, je veux declencher un evenement sur le textview descriptiont "qui recupère l'id de contenut de list çad titrethemet.
voilà mon code java
merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 ... t = (TextView)findViewById(R.id.titrethemet); //pointe sur titrethemet for (int i=0;i<v.size();i++) { map = new HashMap<String, String>(); map.put("theme", v.elementAt(i)); if (v.elementAt(i).toString().equals("Golf")) // le problème ici { t.setBackgroundColor(Color.GREEN); } map.put("description", "C'est le theme de bien etre"); map.put("img", String.valueOf(R.drawable.images3)); listItem.add(map); } //Création d'un SimpleAdapter qui se chargera de mettre les items présent dans notre list (listItem) dans la vue affichageitem SimpleAdapter mSchedule = new SimpleAdapter (this.getBaseContext(), listItem, R.layout.afficheitemteme, new String[] {"theme","img", "description"}, new int[] {R.id.titrethemet,R.id.imgt, R.id.descriptiont}); //On attribut à notre listView l'adapter que l'on vient de créer maListViewPerso.setAdapter(mSchedule);
Partager