1

i used the Android-Universal-Image-Loader(https://github.com/nostra13/Android-Universal-Image-Loader) for my project,but i get a strange problem:

the image loaded from the website was dismatch with the listview item when i scroll fast or fling fast...

i mean the listview item will load the wrong image sometimes,here is the code:

    @Override
public View getView(int position, View convertView, ViewGroup parent) {

    Map<String, Object> item = mDatasource.get(position);
    View view = convertView;
    final ViewHolder holder;

    if (convertView == null) {
        holder = new ViewHolder();
        view = mInflater.inflate(R.layout.block_list_item, null);

        holder.account_name = (TextView) view.findViewById(R.id.author_name);

        holder.account_avatar = (ImageView) view.findViewById(R.id.view_header);

        view.setTag(holder);
    } else {
        holder = (ViewHolder) view.getTag();
    }

    holder.account_name.setText(StringUtils.convertSafeString(item.get("account_name")));
    String avatarUrl = UrlHelper.HOST + item.get("account_avatar");

    if (!avatarUrl.endsWith(Constants.NO_AVATAR)) {

        holder.account_avatar.setTag(avatarUrl);
        imageLoader.displayImage(avatarUrl,holder.account_avatar, mOptions);
    }

    return view;
}

1 Answers1

0

Well, I don't know this is going to help or not I had a similar problem but I was using Parse, meaning I am getting my images from parse server I managed to solve the problem when I discovered that the method I am using to get the image was meant to open a new thread rather than the UI thread and get the image in background (getParseFile().getDataInBackGround), when I changed it to another method which doesn't use another thread(getParseFile().getData()), it worked without problems.