QQ863017854 2016-02-29 08:59 采纳率: 100%
浏览 1756

Android initviews中只执行一次

在json中获取图片链接

        if(picJson.has("slider_pic") == true){
                        slider_pic_URL=picJson.getString("slider_pic");
//                      System.out.println("topview图片链接"+slider_pic_URL);
                        piccList = new JSONArray(slider_pic_URL);
                            for (int j =0; j<piccList.length(); j++) {
                            slider_pic_URL = piccList.getString(j);
                        initViews(slider_pic_URL);//都传递到initViews中

                            System.out.println("wwwwwwwwwwww"+slider_pic_URL);输出两个链接正常
                            }

                                            }

在initViews中赋值给一个jsonarray容器

 private  void initViews(String slider_pic_URL)  {
              llAdvertiseBoard = (LinearLayout) this.findViewById(R.id.llAdvertiseBoard);
            JSONArray advertiseArray = new JSONArray();
            try{
            JSONObject head_img0 = new JSONObject();
            JSONObject head_img1 = new JSONObject();
            System.out.println("picqqqqqqqqqqqqqqqqq"+ slider_pic_URL);这里也照常输出两个链接
           if (slider_pic_URL != null){
               for(int i = 0;i<4;i++)
               {
            head_img0.put("head_img",slider_pic_URL);
            advertiseArray.put(head_img0);
            }
           }
           else{
               return;
           }
            }catch (Exception e) {
                e.printStackTrace();
        };  
    llAdvertiseBoard.addView(new Advertisements(this, true, inflater, 3000).initView(advertiseArray));
            }

问题出在显示的时候只能显示一个图片 求大神解答!!!急
求解决方法 思路

  • 写回答

1条回答

  • devmiao 2016-02-29 09:02
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 MATLAB动图问题
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名