【问题标题】:listview asyncimage mismatchlistview asyncimage 不匹配
【发布时间】:2013-11-15 14:44:16
【问题描述】:

我在我的项目中使用了 Android-Universal-Image-Loader(https://github.com/nostra13/Android-Universal-Image-Loader),但我遇到了一个奇怪的问题:

当我快速滚动或快速滚动时,从网站加载的图像与列表视图项不匹配...

我的意思是列表视图项有时会加载错误的图像,这里是代码:

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

【问题讨论】:

    标签: android-asynctask universal-image-loader convertview


    【解决方案1】:

    好吧,我不知道这会不会有帮助 我遇到了类似的问题,但我使用的是 Parse,这意味着我正在从解析服务器获取图像 当我发现我用来获取图像的方法是打开一个新线程而不是 UI 线程并在后台获取图像 (getParseFile().getDataInBackGround) 时,我设法解决了这个问题,当我将它更改为另一种不使用另一个线程的方法(getParseFile().getData()),它没有问题。

    【讨论】:

      猜你喜欢
      • 2021-12-08
      • 2016-10-14
      • 2022-07-29
      • 2021-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多