在别人调用网页图片的程序 嵌入了自己的程序中 有时候图片会显示不出来 有时候能显示出来 求告知
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);
HealthMap.put("key",slider_pic_URL);//放入URL
System.out.println(slider_pic_URL);//输出URL正确
下面放入
private void initViews() {
llAdvertiseBoard = (LinearLayout) this.findViewById(R.id.llAdvertiseBoard);
JSONArray advertiseArray = new JSONArray();
try{
JSONObject head_img0 = new JSONObject();
head_img0.put("head_img", HealthMap.get("key", isContinue));//取出URL
advertiseArray.put(head_img0);
}catch (Exception e) {
e.printStackTrace();
};
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/wp-content/uploads/2015/10/byf1118.jpg");
advertiseArray.put(head_img0);
下面是所用的 put get 方法
public static class HealthMap {
private static Map<String, Object> map = new ConcurrentHashMap<String, Object>();
/**
* 传值
* @param key
* @param obj
*/
public static void put(String key, Object obj) {
map.put(key, obj);
}
/**
* 取值 默认删除内存引用
* @param key
* @return
*/
public static Object get(String key) {
return map.remove(key);
}
/**
* 取值 自定义是否删除内存引用
* @param key
* @param isDelete
* @return
*/
public static Object get(String key, boolean isDelete) {
if (isDelete) {
return get(key);
} else {
return map.get(key);
}
}
}
求大神解答 !!!