My images are again getting loaded when I scroll my listview.
Here is my getview method of my adapter.
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View itemView = convertView;
// if(itemView==null){
// final int x=position;
Log.e("view Touched..","dsfgvdvgd");
LayoutInflater inflator = ((Activity) context).getLayoutInflater();
// LayoutInflater inflator = getLayoutInflater();
itemView=inflator.inflate(resId, null);
// }
// name
TextView name=(TextView) itemView.findViewById(R.id.userName);
name.setText(usersSS.get(position).getUsername());
TextView state=(TextView) itemView.findViewById(R.id.state);
state.setText(usersSS.get(position).getState());
//image
ImageView img = (ImageView)itemView.findViewById(R.id.userimage);
if(position==3){
Log.e("image urls",usersSS.get(position).getUserthumb());
}
imageLoader.DisplayImage(usersSS.get(position).getUserthumb().replace(" ","%20"), img);
// rating stars..
int[] stars = {R.id.star1,R.id.star2,R.id.star3,R.id.star4,R.id.star5};
if(!usersSS.get(position).getRating().equals(""))
{
int i=Integer.parseInt(usersSS.get(position).getRating());
for(int j=0;j<i;j++)
{
ImageView imgv =(ImageView)itemView.findViewById(stars[j]);
imgv.setBackgroundResource(R.drawable.star_on);
}
}
Log.e("view","view");
return itemView;
}
I tried with keeping, if(convertView==null){} but then,wrong images are loaded first and after scrolling correct images are loaded.
Please help me in solving the issue.