先定义一个集合,也可以用类对象
List<String> strSize = new ArrayList<>();
然后在将要传参的Fragment界面通过Bundle传递参数
String strResult = jsonObject.getString("result");//接收后台传过来的数据
strSize.add(strResult);//存入集合中
DialogJiaTingChengYuanRepeatContractInfoList dialogJiaTingChengYuanRepeatContractInfoList = new DialogJiaTingChengYuanRepeatContractInfoList();
Bundle bundle = new Bundle();
bundle.putSerializable("result", (Serializable) strSize);
bundle.putString("jiaTingHao", item.getJiaTingHao());
bundle.putString("PiLiangUpLoadDataActivity", str);
dialogJiaTingChengYuanRepeatContractInfoList.setArguments(bundle);
dialogJiaTingChengYuanRepeatContractInfoList.show(getFragmentManager(), "DialogJiaTingChengYuanRepeatContractInfoList");
在Dialog界面进行接收
List<String> hjtList = (List<String>) (getArguments().getSerializable("result"));
JSONArray jsonStr= new JSONArray(hjtList.toString());
for (int i = 0; i <jsonStr.length() ; i++) {
JSONArray jsonData = jsonStr.getJSONArray(i);
for (int j = 0; j < jsonData.length(); j++) {
JSONObject jsonObject1 = jsonData.getJSONObject(j);
if(jsonObject1.getInt("code")==1){
JSONObject jsonObject2 = jsonObject1.getJSONObject("data");
data.add(new JiaTingChengYuanRepeatContractInfoListItem(
jsonObject2.getString("depId"),
jsonObject2.getString("depName"),
jsonObject2.getString("CJth"),
jsonObject2.getString("VId"),
jsonObject2.getString("VIdx"),
jsonObject2.getString("CGrbh"),
jsonObject2.getString("VJtlxr"),
jsonObject2.getString("VXm"),
jsonObject2.getString("VJtlxrx")
));
}else if (jsonObject1.getInt("code") == 0) {
}
}
}