问题描述:
我正在创建一个可滚动列表的文章,缩略图由我的sqlite数据库填充.一般来说,它是“工作”,除了缓慢:
图像加载非常缓慢…我以为使用“Universal Image Loader”缓存设备上的图像,这将使它们似乎只是滚动到视图,如果你已经查看了(或至少接近).但是 – 当您向上/向下拖动时,图像中没有任何图像,然后3-5秒钟后,图像开始弹出(就像重新下载它们)
我正在更改缩略图框的可见性,但是这是完美无缺的 – 它们似乎没有改变 – 它们只是滚动到视图中,不闪烁或任何东西. (但是图像不会再出现几秒钟).
我已经通过删除我的PHP脚本,滚动后…当我回滚到上一个点,图像不显示 – 让我假设它从我的PHP脚本加载每一次.
但是根据the docs:“UsingFreqLimitedMemoryCache(超过缓存大小限制时,最常使用的位图被删除) – 默认使用”
细节:
在我的ArticleEntryAdapter.js中我有:
@Override
public View getView(final int position,final View convertView,final ViewGroup parent) {
// We need to get the best view (re-used if possible) and then
// retrieve its corresponding ViewHolder,which optimizes lookup efficiency
final View view = getWorkingView(convertView);
final ViewHolder viewHolder = getViewHolder(view);
final Article article = getItem(position);
// Set the title
viewHolder.titleView.setText(article.title);
//Set the subtitle (subhead) or description
if(article.subtitle != null)
{
viewHolder.subTitleView.setText(article.subtitle);
}
else if(article.description != null)
{
viewHolder.subTitleView.setText(article.description);
}
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.displayImage("",viewHolder.thumbView); //clears prevIoUs one
if(article.filepath != null && article.filepath.length() != 0) {
imageLoader.displayImage(
"http://img.sltdb.com/processes/resize.PHP?image=" + article.filepath + "&size=100&quality=70",viewHolder.thumbView
);
viewHolder.thumbView.setVisibility(View.VISIBLE);
} else {
viewHolder.thumbView.setVisibility(View.GONE);
}
return view;
}
只要图像不正确 – 它不是经常的,但有时滚动时,我会看到相同的图像2,当我看文章时,它们并不完全相关(即没有机会实际使用相同的图像)所以 – 我滚开它,并回来,它不再是不正确的图像.
注意:我是Java / Android的新手 – 您可能已经注意到了.
每个注释请求的更多代码:
private View getWorkingView(final View convertView) {
// The workingView is basically just the convertView re-used if possible
// or inflated new if not possible
View workingView = null;
if(null == convertView) {
final Context context = getContext();
final LayoutInflater inflater = (LayoutInflater)context.getSystemService
(Context.LAYOUT_INFLATER_SERVICE);
workingView = inflater.inflate(articleItemLayoutResource,null);
} else {
workingView = convertView;
}
return workingView;
}
更新:
我的清单文件有:
但是我发现的缓存文件夹完全是空的:
mnt
-sdcard
-Android
-data
-com.mysite.news
-cache
-uil-images