Bonjour,

j'ai tenter de faire une adaptation de mon programme à l'aide de ce tuto:
http://mickael-lt.developpez.com/tut...iser-listview/

Cependant je ne comprends pas il ne m'afffiche pas mes données.

Mes données sont une arrayList de client récupérer dans une base de donnée via un textView que je remplis et que je tente d'afficher via une listView.

activity_recherche_client_display.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
<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/ListView01" 
		android:layout_width="wrap_content"
		android:layout_height="wrap_content">
	</ListView>
</LinearLayout>

RechercheClientDisaplay.java
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package com.example.softwaredatabase;
 
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
 
import org.apache.http.*;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
 
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
 
import android.app.ListActivity;
import android.net.ParseException;
import android.os.*;
import android.util.*;
import android.view.*;
import android.view.View.OnClickListener;
import android.widget.*;
 
 
public class RechercheClientDisplay extends ListActivity {
    /** Called when the activity is first created. */
	private String rechercheClient;
	private ArrayList<Client> donnees = new ArrayList<Client>();
	private String result = null;
	private InputStream is = null;
	private JSONObject json_data=null;
	private ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
	private boolean bool;
	private TextView selection;
	private enum Table {field_name};
 
 
 
	@Override
    public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.activity_recherche_client_display);
 
	     //récupération de la variable
	     Bundle extra = getIntent().getExtras();
	     rechercheClient = extra.getString("rechercheClient"); 
 
	    // Envoyer la requête au script PHP.
	  	nameValuePairs.add(new BasicNameValuePair("rechercheClient",rechercheClient));
 
 
 
	  Button returnButton = (Button) findViewById(R.id.retour);
		returnButton.setOnClickListener(new OnClickListener() {
 
			@Override
			public void onClick(View v) {
				finish();
			}
		});
 
     try{
     //commandes httpClient
     HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://10.0.2.2/Applications/rechercheClient.php");
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity entity = response.getEntity();
        is = entity.getContent();
     }
     catch(Exception e){
      Log.i("taghttppost",""+e.toString());
            Toast.makeText(getBaseContext(),e.toString() ,Toast.LENGTH_LONG).show();
       }
 
 
     //conversion de la réponse en chaine de caractère
        try
        {
         BufferedReader reader = new BufferedReader(new InputStreamReader(is,"UTF-8"));
 
         StringBuilder sb  = new StringBuilder();
 
         String line = null;
 
         while ((line = reader.readLine()) != null)
         {
        	 sb.append(line + "\n");
        	 bool = false;
         }
 
         is.close();
 
         result = sb.toString();
        }
        catch(Exception e)
        {
         Log.i("tagconvertstr",""+e.toString());
         bool = false;
        }
        //recuperation des donnees json
        try{
          JSONArray jArray = new JSONArray(result);
 
             for(int i=0;i<jArray.length();i++)
             {
 
                   json_data = jArray.getJSONObject(i);
                   donnees.add(new Client (json_data.getString("LAST_NAME"), json_data.getString("FIRST_NAME")));
              }
             bool = true;
            }
            catch(JSONException e){
             Log.i("tagjsonexp",""+e.toString());
             bool = false;
            } catch (ParseException e) {
             Log.i("tagjsonpars",""+e.toString());
  	             bool = false;
  	            } 
 
 
        if (bool){
        	//selection = (TextView) findViewById(R.id.selection);
            //setListAdapter(new TableAdapter(this));
 
 
        	//Création et initialisation de l'Adapter pour les personnes
            ClientAdapter adapter = new ClientAdapter(this, donnees);
 
            //Récupération du composant ListView
            ListView list = (ListView)findViewById(R.id.ListView01);
 
            //Initialisation de la liste avec les données
            list.setAdapter(adapter);
 
		}
		else{
			Toast.makeText(RechercheClientDisplay.this,
					R.string.erreur2,
					Toast.LENGTH_SHORT).show();
			finish();
		}       
 
  	}
}

Erreur LogCat
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
01-02 11:15:20.333: D/AndroidRuntime(632): Shutting down VM
01-02 11:15:20.333: W/dalvikvm(632): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
01-02 11:15:20.333: E/AndroidRuntime(632): Uncaught handler: thread main exiting due to uncaught exception
01-02 11:15:20.384: E/AndroidRuntime(632): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.softwaredatabase/com.example.softwaredatabase.RechercheClientDisplay}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
01-02 11:15:20.384: E/AndroidRuntime(632): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
01-02 11:15:20.384: E/AndroidRuntime(632): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
01-02 11:15:20.384: E/AndroidRuntime(632): 	at android.app.ActivityThread.access$2200(ActivityThread.java:119)
01-02 11:15:20.384: E/AndroidRuntime(632): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
01-02 11:15:20.384: E/AndroidRuntime(632): 	at android.os.Handler.dispatchMessage(Handler.java:99)
01-02 11:15:20.384: E/AndroidRuntime(632): 	at android.os.Looper.loop(Looper.java:123)
01-02 11:15:20.384: E/AndroidRuntime(632): 	at android.app.ActivityThread.main(ActivityThread.java:4363)
01-02 11:15:20.384: E/AndroidRuntime(632): 	at java.lang.reflect.Method.invokeNative(Native Method)
01-02 11:15:20.384: E/AndroidRuntime(632): 	at java.lang.reflect.Method.invoke(Method.java:521)
01-02 11:15:20.384: E/AndroidRuntime(632): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-02 11:15:20.384: E/AndroidRuntime(632): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-02 11:15:20.384: E/AndroidRuntime(632): 	at dalvik.system.NativeStart.main(Native Method)
01-02 11:15:20.384: E/AndroidRuntime(632): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
01-02 11:15:20.384: E/AndroidRuntime(632): 	at android.app.ListActivity.onContentChanged(ListActivity.java:236)
01-02 11:15:20.384: E/AndroidRuntime(632): 	at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:201)
01-02 11:15:20.384: E/AndroidRuntime(632): 	at android.app.Activity.setContentView(Activity.java:1622)
01-02 11:15:20.384: E/AndroidRuntime(632): 	at com.example.softwaredatabase.RechercheClientDisplay.onCreate(RechercheClientDisplay.java:45)
01-02 11:15:20.384: E/AndroidRuntime(632): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-02 11:15:20.384: E/AndroidRuntime(632): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
01-02 11:15:20.384: E/AndroidRuntime(632): 	... 11 more
01-02 11:15:20.454: I/dalvikvm(632): threadid=7: reacting to signal 3
01-02 11:15:20.523: I/dalvikvm(632): Wrote stack trace to '/data/anr/traces.txt'
01-02 11:15:21.983: I/Process(632): Sending signal. PID: 632 SIG: 9
01-02 11:15:23.384: D/ddm-heap(638): Got feature list request
01-02 11:15:23.804: D/dalvikvm(638): GC freed 570 objects / 49360 bytes in 225ms

Il y a un probleme avec la listView android.R.id.list alors que dans mon xml ma liste se nomme ListView01

Si voux pouviez m'aider.
Cordialement.