我已经确保我只有一个 ImageLoader 实例,所以我知道这不是问题,由于某种原因,它只会在显示从网络加载的全新图像时滞后。所以我假设它与 UI 卡顿的事实有关,因为它正在解码图像,但我虽然 Universal Image Loader 异步处理了所有事情。这是我的 BaseAdapter 的 getView 方法的内容。
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
JSONObject thePost = null;
try {
thePost = mPosts.getJSONObject(position).getJSONObject("data");
} catch (Exception e) {
System.out.println("errreoroer");
}
LinearLayout postItem = (LinearLayout) inflater.inflate(R.layout.column_post, parent, false);
String postThumbnailUrl = null;
try {
//parse thumbnail
postThumbnailUrl = thePost.getString("thumbnail");
} catch (Exception e) {}
//grab the post view objects
ImageView postThumbnailView = (ImageView)postItem.findViewById(R.id.thumbnail);
if (!(postThumbnailUrl.equals("self") || postThumbnailUrl.equals("default") || postThumbnailUrl.equals("nsfw")))
mImageLoader.displayImage(postThumbnailUrl, postThumbnailView);
return postItem;
}