我创建一个应用程序,在我的应用我使用JSON解析,我发送请求到服务器
I am creating one application,in my application I am using json parsing,I am sending request to server for
点击按钮请求将被发送后,我会得到响应
after click on button request will be send,and i will get response
{"searchresult":
[ {"match_detail_id":369,"profile_id":"GM686317","name":"Sonal Patel","image":"","location":"Rajkot ,Gujarat ,India","mothertongue":"Gujarati","religion":"Hindu","occupation":"Professor \/ Lecturer","education":"Masters - Arts\/ Science\/ Commerce\/ Others"}
, {"match_detail_id":396,"profile_id":"GM780609","name":"Hetal Trivedi","image":"","location":"Rajkot ,Gujarat ,India","mothertongue":"Gujarati","religion":"Hindu","occupation":"Administrative Professional","education":"Bachelors - Arts\/ Science\/ Commerce\/ Others"}
, {"match_detail_id":1078,"profile_id":"GM540027","name":"Shruti Dave","image":"","location":"Rajkot ,Gujarat ,India","mothertongue":"Gujarati","religion":"Hindu","occupation":"Education Professional","education":"Masters - Arts\/ Science\/ Commerce\/ Others"}
]
}
我要显示在另一个活动的这种反应
I want to show this response in another activity
解析您收到的响应,并将其存储在与您创建来存储您的每一个响应行自定义对象的ArrayList
Parse the response you have received, and store it in a arrayList with the custom object you create to store your each response line.
{"match_detail_id":369,"profile_id":"GM686317","name":"Sonal Patel","image":"","location":"Rajkot ,Gujarat ,India","mothertongue":"Gujarati","religion":"Hindu","occupation":"Professor \/ Lecturer","education":"Masters - Arts\/ Science\/ Commerce\/ Others"}
这是你的一条线,让对象类会是这样 -
this is your one line, so object class would be like this -
public class ResultObejct implements parcelable {
String match_detail_id;
String profile_id;
String name;
String image;
public String getName(){ //set getter and setters
return this.name;
...
...
...
}
和像这个环节,把你的数据的意图,
And Like this link, put your data in intent,
Intent i = new Intent(...);
i.putExtra("data", new DataWrapper(yourArrayList));
和检索下一个活动:
DataWrapper dw = (DataWrapper) getIntent().getSerializableExtra("data");
ArrayList<Parliament> list = dw.getParliaments();
上一篇:如何获得驱动两个位置之间的距离?如何获得、距离、位置、两个
下一篇:java.lang.RuntimeException的:无法恢复活动{packagename.classname}:lang、java、RuntimeException、classname