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;
}
4

1 回答 1

0

好吧,我不知道这是否会有所帮助获取图像是为了打开一个新线程而不是 UI 线程并在后台获取图像 (getParseFile().getDataInBackGround),当我将它更改为不使用另一个线程的另一个方法时 (getParseFile().getData( )),它工作没有问题。

于 2016-11-20T13:32:27.637 回答