在別人調用網頁圖片的程序 嵌入了自己的程序中 有時候圖片會顯示不出來 有時候能顯示出來 求告知
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);
}
}
}
求大神解答 !!!
**求大神來幫忙 在線等 急 **