我正在创建一个应用程序,在我的应用程序中我正在使用json解析,我正在向服务器发送请求
点击按钮后会发送请求,我会得到回应
{"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"}
]
}
我想在另一项活动中显示此回复
答案 0 :(得分:0)
将响应数据存储在地图中并将其传递给下一个活动。
答案 1 :(得分:0)
解析您收到的响应,并将其存储在arrayList中,并使用您创建的自定义对象存储每个响应行。
{"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"}
这是你的一行,所以对象类就是这样 -
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;
...
...
...
}
并Like this link,将您的数据置于意图中,
Intent i = new Intent(...);
i.putExtra("data", new DataWrapper(yourArrayList));
并在下一个活动中检索:
DataWrapper dw = (DataWrapper) getIntent().getSerializableExtra("data");
ArrayList<Parliament> list = dw.getParliaments();