CustomAdapter / getView()只调用一次?

时间:2016-03-20 20:01:34

标签: android android-studio adapter baseadapter getview

为什么getView方法只调用一次?没有回报?

这是我的代码

public class GridViewAdapter extends BaseAdapter {

Context mContext;
ArrayList<String> list;

GridViewAdapter(Context context,ArrayList<String> list){
    this.mContext = context;
    this.list = new ArrayList<>(list);
}

@Override
public int getCount() {
    return list.size();
}

@Override
public Object getItem(int position) {
    return list.get(position);
}

@Override
public long getItemId(int position) {
    return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    ImageView view = (ImageView) convertView;

    if(view==null){
        view = new ImageView(mContext);
    }
    Picasso.with(mContext).load(String.valueOf(list.get(position))).resize(360, 512).into(view);
    return view;
}

}

注意:传递的arrayList的大小是20!所以它不是空列表!

1 个答案:

答案 0 :(得分:0)

尝试扩展

ArrayAdapter<String>