我想通过intent从一个Activity转移到另一个ArrayList.我怎么能这样做,因为我无法实现JSONObject类parcelable
您可以简单地将整个JSONObject作为字符串.
intent.putString("YOUR_KEY", jsonObj.toString);
Run Code Online (Sandbox Code Playgroud)
然后在SecondActivity中,您可以将Json String转换为JsonObject
JSONObject jsonObj = new JSONObject(getIntent().getStringExtra("YOUR_KEY"));
Run Code Online (Sandbox Code Playgroud)
你可以创建一个ArrayList,即json.ToString()
JSONObject json1 = null,json2 = null;
ArrayList<String> jsonList=new ArrayList<String>();
jsonList.add(json1.toString());
jsonList.add(json2.toString());
i.putStringArrayListExtra("json_list", jsonList);
Run Code Online (Sandbox Code Playgroud)
然后在SecondActivity中,您可以将Json String转换为JsonObject
JSONObject jsonObj1 = new JSONObject(getIntent().getStringExtra("json_list").get(0));
JSONObject jsonObj2 = new JSONObject(getIntent().getStringExtra("json_list").get(1));
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3500 次 |
最近记录: |