Monday, 12 August 2013

Images in gridview change their position while scrolling

Images in gridview change their position while scrolling

Hi i'm having this kind of problem, when scrolling imageviews change their
positions and their background images. I saw other answers on this topic
on this site, but non of them helped me.
Like this once: grid view scrolling issue GridView scrolling problem on
Android GridView elements changes their place dynamically when scroll
screen
and many others...but they don't solve my problem.
Important thing is that i don't use custom layout for gridview or gridview
items(imageViews).I create them programmatically. This is very important
to me so if someone know the answer pls help me...Thanks.
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView==null){
imageView = new ImageView(ctx);
} else {
imageView = (ImageView) convertView;
}
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8);
imageView.setBackgroundResource(tmp[position]);
imageView.setImageResource(blank);
return imageView;
}

No comments:

Post a Comment