GridView elements changes their place dynamically when scroll screen
You should change your
getView method like this. public View getView(int position, View convertView, ViewGroup parent){
// TODO Auto-generated method stub
View v;
if(convertView==null)
{
LayoutInflater li = getLayoutInflater();
v = li.inflate(R.layout.icontext, null);
}else{
v = convertView;
}
TextView tv = (TextView)v.findViewById(R.id.icon_text);
tv.setText(providers[position]);
ImageView iv = (ImageView)v.findViewById(R.id.icon_image);
iv.setImageResource(R.drawable.icon);
return v;
}
Your problem is that when you use
convertView it stores old data form the first records. Convert view is used to avoid layout inflation from resource which costs you time and memory. You should use the old inflated view, but set new data.
Comments
Post a Comment