pgc_tel 2015-09-18 08:18 采纳率: 0%
浏览 1597

设置适配器后不执行getView方法,是怎么回事

//重写了PullToRefreshAdapterViewBase ,给他设置适配器
private List> list;
private LayoutInflater layoutinflater;
private ImageLoader imageLoader;
private g gable;
private Context context;
public ListAdapter(Context context,
List> list, g gable,
ImageLoader imageLoader) {
// 实例化ImageLoaderConfiguration
this.context = context;
this.gable = gable;
this.imageLoader = imageLoader;
this.layoutinflater = LayoutInflater.from(context);
this.list = list;
System.out.println("进入ListAdapter");
System.out.println(list.size());//这里是可以打印的,但是到这就没了后续
}

@Override
public int getCount() {
    // TODO Auto-generated method stub
    return list.size();
}

@Override
public Object getItem(int position) {
    // TODO Auto-generated method stub
    return list.get(position);
}

@Override
public long getItemId(int position) {
    // TODO Auto-generated method stub
    return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
     System.out.println("进入getview");
        convertView = layoutinflater.inflate(R.layout.news_list_item,
                null);
    System.out.println(list.size());
    HashMap<String, Object> HashMap =list.get(position);

    ImageView iv = (ImageView) convertView.findViewById(R.id.news_list_iv);     
    TextView tv = (TextView) convertView.findViewById(R.id.news_list_tv);
    TextView dt = (TextView) convertView.findViewById(R.id.news_list_date);

// if (HashMap.size()>0) {
// for (int i = 0; i < HashMap.size(); i++) {
//

String file = (String) HashMap.get("file");
System.out.println(file+"111111");
String name = (String) HashMap.get("name");
System.out.println(name+"111111");
String lessonType = (String) HashMap.get("lessonType");
String img = (String) HashMap.get("image");
int image = Integer.parseInt(img);
if (image==0) {
imageLoader.displayImage("http://le.xianzaixue.com/image/lesson/"+ lessonType + ".jpg", iv,
gable.initDisplayImageOptions());
}else if(image==1){
String folder = (String) HashMap.get("folder");
imageLoader.displayImage("http://le.xianzaixue.com/"+folder+"/"+file.substring(0, 8)+"/"+file.substring(8, 14)+".jpg", iv,
gable.initDisplayImageOptions());
}

            tv.setText(name);
            dt.setText(file.substring(0, 4) + "-" + file.substring(4, 6) + "-"
                    + file.substring(6, 8));

// }
// }

    return convertView;
}
  • 写回答

2条回答 默认 最新

  • bdmh 移动开发领域优质创作者 2015-09-18 08:26
    关注

    你的list在哪填充的数据,list中没值吧

    评论

报告相同问题?

悬赏问题

  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容