Salut,
A l'aide d'un tutoriel j'ai pu afficher les données du Json en utilisant GSON, celles-ci s'affichent a l'aide d'un TextView..
J'aimerais afficher les informations de ce Json en ListView....
Merci d'avance pour votre aide.
Voici mon code :
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 class ViewDurchsuchen extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.durchsuchen_layout); list = (TextView) findViewById(R.id.list); new AsyncTask<Void, Void, Void>() { @Override protected void onPreExecute() { super.onPreExecute(); progressDialog = new ProgressDialog(ViewDurchsuchen.this); progressDialog.setCancelable(false); progressDialog.setMessage("Loading..."); progressDialog.show();} @Override protected Void doInBackground(Void... voids) { Reader reader=API.getData("http://bucapp.de/bcarest.php?getRelations=1"); Type listType = new TypeToken<ArrayList<ContactModel>>(){}.getType(); beanPostArrayList = new GsonBuilder().create().fromJson(reader, listType); postList=new StringBuffer(); for(ContactModel post: beanPostArrayList){ postList.append("\n ID: "+post.getID()+"\n firstname: "+post.getFirstname()+"\n phone: "+post.getPhone()+"\n email: "+post.getEmail()+"\n\n"); } return null; } @Override protected void onPostExecute(Void aVoid) { super.onPostExecute(aVoid); progressDialog.dismiss(); list.setText(postList); } }.execute(); } }
Partager