如何显示在其他活动JSON响应? [英] How to show json response in other activity?

查看:91
本文介绍了如何显示在其他活动JSON响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个应用程序,在我的应用我使用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();

这篇关于如何显示在其他活动JSON响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆