Bonjour,

J'ai un adapter perso pour une ListView.
Chaque ligne de ma ListView gère deux TextView.

Lorsque je déclare un OnClickListener dans mon adapter, je ne reçois pas toujours l'évènement dans mon activity.
Si je ne les déclare pas, tout fonctionne correctement.
Malheureusement j'ai besoin de les déclarer pour savoir quel item a été cliqué.

Voici la méthode dans l'activity:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
 
protected void onListItemClick(ListView l, View v, int position, long id) {
 
    	Log.e("Click receive", "Click receive");
        super.onListItemClick(l, v, position, id);	
 
	}
et la méthode getView:

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
 
public View getView(int p_position, View convertView, ViewGroup parent) {
               View v = convertView;
                 if (v == null) {
                   LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                   v = vi.inflate(id, null);
               }
               final Bean b = items.get(p_position);
               if (b != null) {
                       TextView t1 = (TextView) v.findViewById(R.id.TextBeanView01);
                       ImageView p1 = (ImageView) v.findViewById(R.acountcreation.PictView01);
 
                       if(t1!=null)
                       {
                       	t1.setText(b.getName());
                       	t1.setFocusable(false);
                       	t1.setFocusableInTouchMode(false);
 
                       	t1.setOnClickListener(new OnClickListener() {
 
                  			public void onClick(View v) {
                  				Log.e("CLICK", "CLICK ON T1 " + b.getName());
                  				b.setType(0);
                  			}
                  		});
                       }
 
                       if(p1!=null)
                       {
                       	p1.setOnClickListener(new OnClickListener() {
 
                  			public void onClick(View v) {
                  				Log.e("CLICK", "CLICK ON Picture " + b.getName());
                  				b.setType(1);
                  			}
                  		});
                       }
 
 
               }
               return v;
       }
Le xml:

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
 
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_height="wrap_content" android:orientation="horizontal" android:layout_width="fill_parent"
  android:descendantFocusability="afterDescendants">
 
	<TextView android:text="@+id/TextView01" 
	    android:id="@+id/TextBeanView01" 
	    android:layout_width="wrap_content" 
	    android:layout_height="wrap_content" 
	    android:singleLine="true" 
	    android:textStyle="bold" 
	    android:layout_marginTop="5dip" 
	    android:layout_marginLeft="5dip"
	    android:descendantFocusability="afterDescendants">
 
	</TextView>
 
	<ImageView 
	    android:layout_width="fill_parent" 
	    android:id="@+acountcreation/PictView01"
		android:layout_height="wrap_content"
		android:descendantFocusability="afterDescendants"
		android:src="@drawable/ajouter" android:layout_marginTop="10dp">
	</ImageView>
</LinearLayout>
Un exemple de séquence:

- CLICK ON T1.
- CLICK ON T1.
- CLICK ON T1.
- Click receive.

De temps en temps ça marche bien.

Quelqu'un pourrait m'aider?

Merci beaucoup.