AQuery(Android的查询)如何实际加载图像 [英] AQuery (Android Query) How to load images actually
问题描述
我目前使用 Android的查询图像库从服务器负载。
I am currently using Android Query library for image loading from server.
主要PROB:
我想存储图像第一次,然后后,我想从缓存中加载图像。
我在这里看到的选项缓存控制使用< STRONG>的内存缓存的和 fileCache 的,但我没有得到这是更好地使用的互联网连接速度慢和最小的内存使用
我可能已经以下解决方法:
I have probably following solution with some confusion:
首先我已经使用这样的:(的内存缓存的和的 fileCache 的两个真正
)
First of all i have used like this:( memCache and fileCache both true
)
aq.id(holder.prodImage).image(holder.prodImagePath, true, true, 0, R.drawable.no_image, aq.getCachedImage(R.drawable.no_image), AQuery.FADE_IN);
但这里他说,,如果图像是巨大的,避免内存缓存
但我得到的问题,而网络速度慢,内存不够
然后后,我曾尝试延迟图像加载:
if(aq.shouldDelay(position, convertView, parent, holder.prodImagePath)){
aq.id(holder.prodImage).image(R.drawable.no_image);
} else {
aq.id(holder.prodImage).progress(view.findViewById(R.id.progressBar1)).image(holder.prodImagePath, false, true, 0, 0, null, AQuery.FADE_IN);
}
但其投掷 NullPointerException异常
类似以下内容:
12-10 12:11:26.492: E/AndroidRuntime(23309): java.lang.NullPointerException
12-10 12:11:26.492: E/AndroidRuntime(23309): at com.androidquery.util.Common.shouldDelay(Common.java:328)
12-10 12:11:26.492: E/AndroidRuntime(23309): at com.androidquery.util.Common.shouldDelay(Common.java:340)
12-10 12:11:26.492: E/AndroidRuntime(23309): at com.androidquery.AbstractAQuery.shouldDelay(AbstractAQuery.java:2389)
12-10 12:11:26.492: E/AndroidRuntime(23309): at com.salesman.fragments.ProductFragment$MyGridViewAdapter.getView(ProductFragment.java:423)
12-10 12:11:26.492: E/AndroidRuntime(23309): at android.widget.AbsListView.obtainView(AbsListView.java:2477)
12-10 12:11:26.492: E/AndroidRuntime(23309): at android.widget.GridView.makeAndAddView(GridView.java:1331)
12-10 12:11:26.492: E/AndroidRuntime(23309): at android.widget.GridView.makeRow(GridView.java:331)
12-10 12:11:26.492: E/AndroidRuntime(23309): at android.widget.GridView.fillDown(GridView.java:283)
12-10 12:11:26.492: E/AndroidRuntime(23309): at android.widget.GridView.fillGap(GridView.java:243)
12-10 12:11:26.492: E/AndroidRuntime(23309): at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5549)
12-10 12:11:26.492: E/AndroidRuntime(23309): at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4693)
我能做些什么,我怎么使用这个库对于这个简单的问题。
what can i do and how i used this library for this simple problem
请给我解决方案。
您的帮助,将鸭preciated。
Your Help would be Appreciated.
推荐答案
终于得到了与以下code解决方案:
Finally got the solution with following code:
/* Settings of Image */
//set the max number of concurrent network connections, default is 4
AjaxCallback.setNetworkLimit(8);
//set the max number of icons (image width <= 50) to be cached in memory, default is 20
BitmapAjaxCallback.setIconCacheLimit(50);
//set the max number of images (image width > 50) to be cached in memory, default is 20
BitmapAjaxCallback.setCacheLimit(50);
aq = new AQuery(context);
/* Getting Images from Server and stored in cache */
aq.id(holder.prodImageView).progress(convertView.findViewById(R.id.progressBar1)).image(holder.prodImagePath, true, true, 0, R.drawable.no_image, null, AQuery.FADE_IN);
注释这里如果你没有得到,并有任何问题。
Comment here if you didn't get and have any problem.
感谢。
这篇关于AQuery(Android的查询)如何实际加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!