androidandroid-studioadapterbaseadaptergetview

CustomAdapter / getView() called only once?


why the getView method called only once ? and return nothing ?

here is my code

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;
}

}

note : the size of arrayList passed is 20 ! so it's not empty list !


Solution

  • Try extending

    ArrayAdapter<String>