the json looks like this:
[{"id":"1","name":"Mihai","email":"mihai@yahoo.com","password":"1234","phone":"765889345"},{"id":"2","name":"Robin","email":"robin@yahoo.com","password":"1234","phone":"765453434"}]
the code
// Json
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.penaltyDialog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll()
.penaltyLog()
.build());
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
.detectDiskWrites()
.detectNetwork() // or .detectAll() for all detectable problems
.penaltyLog()
.build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
.detectLeakedSqlLiteObjects()
.penaltyLog()
.penaltyDeath()
.build());
TextView uid = (TextView) findViewById(R.id.titlu_anunt1);
TextView name1 = (TextView) findViewById(R.id.descriere_anunt1);
TextView email1 = (TextView) findViewById(R.id.telefon_anunt1);
JSONObject json = null;
String str = "";
HttpResponse response;
HttpClient myClient = new DefaultHttpClient();
HttpPost myConnection = new HttpPost("http://appz.esy.es/get_user.php");
try {
response = myClient.execute(myConnection);
str = EntityUtils.toString(response.getEntity(), "UTF-8");
}
catch (ClientProtocolException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
try {
JSONArray jArray = new JSONArray(str);
json = jArray.getJSONObject(0);
uid.setText(json.getString("id"));
name1.setText(json.getString("name"));
email1.setText(json.getString("email"));
}
catch (JSONException e) {
e.printStackTrace();
}
How can I add all the objects to my textviews? Right now I can only display one object from json in my first textview, I want to increment the id. I want to display the id1 information: name, location and other stuff in textviews 1. After that I want to display for id2 the name and location into textviews 2.