Reputation: 451
Items disappears while scrolling Gridview very fast. Also the image dimension changes while scrolling fastly. Here is my code :
public View getView(final int position, View gridView, ViewGroup parent) {
final ViewHolder holder;
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (gridView == null) {
holder = new ViewHolder();
gridView = new View(context);
gridView = inflater.inflate( R.layout.view_initial_gallery, null);
holder.dirname = (TextView) gridView.findViewById(R.id.fname);
holder.dirimg = (ImageView) gridView.findViewById(R.id.folder);
holder.tick = (ImageView) gridView.findViewById(R.id.tick);
File file=folders.get(position).getFilelist().get(0);
holder.dirname.setText(folders.get(position).getFoldername());
Picasso.with(context)
.load(new File(file.getPath()))
.resize(300, 300)
.centerCrop()
.into(holder.dirimg);
gridView.setTag(holder);
}
else
{
holder = (ViewHolder)gridView.getTag();
}
return gridView;
}
Upvotes: 3
Views: 1064
Reputation: 709
I have fixed the issue with notifyDataSetChanged(). Hope it will work for you also.
mGridView.setOnScrollListener(new AbsListView.OnScrollListener() {
// Boolean isScrollStop=false;
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
mAdapter.notifyDataSetChanged();
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount){
}
});
Upvotes: 1
Reputation: 1
I had the same issue, except that I used Glide instead of Picasso for image loading. I'm guessing your ImageView's dimensions are set to wrap_content
. Try setting height and width to explicit values in dp's, it worked for me.
Upvotes: 0