I am working on app which has a GridView of images but the last item in GridView is a button that loads more item into Grid. But i am facing a strange issue and that is Butt
I post full getView
method from my other answer. Simple you check the position first. If it's the last item (load more button) return layout immediately.
private final Media special = new Media("-1", "", "", "", "");
public MediaGridAdapter(Context context, int imageID, ArrayList<Media> array, int type, boolean isGetMore) {
list = array;
mediaType = type;
this.context = context;
if(list != null) {
list.add(special);
}
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
RelativeLayout item;
ViewHolder holder;
//this part check it's the last item. -1 is my special item id in contructor.
if(list.get(position).getId().equals("-1")) {
item = (RelativeLayout) LayoutInflater.from(context).inflate(R.layout.item_special_more, null);
item.setTag(MORE_BUTTON);
return item;
}
//
if(convertView == null || convertView.getTag().toString().equals(MORE_BUTTON)) {
Context context = parent.getContext();
item = (RelativeLayout) LayoutInflater.from(context).inflate(R.layout.item_with_icon_vertical, null);
holder = new ViewHolder();
holder.thumbnail = (ImageView) item.findViewById(R.id.iv_icon_media);
item.setTag(holder);
} else {
item = (RelativeLayout) convertView;
holder = (ViewHolder) item.getTag();
}
}
// set data.
holder.thumbnail.setBitmap(...)
return item;
Maybe you can try delete row==null
and holder = (ViewHolder)row.getTag();
it's because of recycle issue,you can have a try first.But it will affect efficiency. Another thing i want to say,how do position==thumbUrls.size();
? Maybe it's position==thumbUrls.size()-1;
.Ok,that's my view,i help it work.