问题描述
- 设置适配器后不执行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; }
解决方案
你的list在哪填充的数据,list中没值吧
解决方案二:
你有没有为listview设置适配器啊