try {
JSONObject object = new JSONObject(jsonData);
String status = object.getString("status");
System.out.print(status);
String postsstr = object.getString("posts");
JSONArray ports = new JSONArray(postsstr);
for(int i = 0;i<ports.length();i++){
port = ports.getJSONObject(i);
id = port.getString("id");
title = port.getString("title");
custom_fields = port.getString("custom_fields");
// System.out.print(custom_fields);
picJson = new JSONObject(custom_fields);
if(picJson.has("slider_pic") == true){
slider_pic_URL=picJson.getString("slider_pic");
System.out.println("图片链接"+slider_pic_URL);
picList = new JSONArray(slider_pic_URL);
for (int j =0; j<picList.length(); j++) {
slider_pic_URL = picList.getString(j);
System.out.println(slider_pic_URL);}
想把这里的slider_pic_URL 传递到initviews()中
private void initViews() {
llAdvertiseBoard = (LinearLayout) this.findViewById(R.id.llAdvertiseBoard);
final JSONArray advertiseArray = new JSONArray();
class receiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
// TODO 自动生成的方法存根
String TPRUL =intent.getStringExtra("tpv");
System.out.println(TPRUL);
advertiseArray.put(TPRUL);
}
}
llAdvertiseBoard.addView(new Advertisements(this, true, inflater, 3000).initView(advertiseArray));
// try {
// JSONObject head_img0 = new JSONObject();
// head_img0.put("head_img","http://www.zjhaining.com/uploads/2015/10/byf1118.jpg");
//
//
// advertiseArray.put(head_img0);
//
//
// } catch (JSONException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
}
在initviews中创建了一个json数组 想把handler中解析出的链接传递给initviews中的
json数组中 从而可以加载出链接 急 求解答 我试了用intent 不行