问题描述
我要GridView和使用Android系统的通用 - 图像 - 装载机的ListView。
我下载并修改它。
它工作正常,但是当我改变,移动源到另一个项目,它的崩溃。
我不知道为什么:(
有没有错误,任何错误消息。
我认为这是零点错误或启动库。
我认为错误会带有这个部分。
的ListView =(GridView控件)findViewById(R.id.gridview);
((GridView控件)的ListView).setAdapter(新ImageAdapter());
和
公共类ImageAdapter延伸BaseAdapter {
@覆盖
公众诠释的getCount(){
Log.v(猫头鹰,测试1);
返回imageUrls.length;
} @覆盖
公共对象的getItem(INT位置){
Log.v(OWL,TEST2);
返回null;
} @覆盖
众长getItemId(INT位置){
Log.v(OWL,TEST3);
返回的位置;
} @覆盖
公共查看getView(INT位置,查看convertView,父母的ViewGroup){
Log.v(OWL,TEST4);
最后ImageView的ImageView的;
如果(convertView == NULL){
ImageView的=(ImageView的)getLayoutInflater()膨胀(R.layout.item_grid_image,父母,假的)。
Log.v(OWL,TEST5);
}其他{
ImageView的=(ImageView的)convertView;
Log.v(OWL,TEST6);
} imageLoader.displayImage(imageUrls [位置],ImageView的,期权);
Log.v(OWL,TEST7);
返回ImageView的;
}
}
我看不到TEST6,TEST7在logcat的
我连接日志的打击。请帮我或我let't知道如何使用该库。
03-25 18:24:17.208:D / AndroidRuntime(312):关闭VM
03-25 18:24:17.208:W / dalvikvm(312):主题ID = 1:螺纹未捕获的异常(组= 0x41693438)退出
03-25 18:24:17.228:E / AndroidRuntime(312):致命异常:主要
03-25 18:24:17.228:E / AndroidRuntime(312):java.lang.IllegalStateException:ImageLoader的必须配置使用前是init
03-25 18:24:17.228:E / AndroidRuntime(312):在com.nostra13.universalimageloader.core.ImageLoader.checkConfiguration(ImageLoader.java:359)
03-25 18:24:17.228:E / AndroidRuntime(312):在com.nostra13.universalimageloader.core.ImageLoader.displayImage(ImageLoader.java:200)
03-25 18:24:17.228:E / AndroidRuntime(312):在com.nostra13.universalimageloader.core.ImageLoader.displayImage(ImageLoader.java:162)
03-25 18:24:17.228:E / AndroidRuntime(312):在com.kmob.camera.ImageGridActivity $ ImageAdapter.getView(ImageGridActivity.java:117)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.widget.AbsListView.obtainView(AbsListView.java:2449)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.widget.GridView.onMeasure(GridView.java:1030)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.view.View.measure(View.java:15364)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.view.View.measure(View.java:15364)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4824)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.view.View.measure(View.java:15364)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4824)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.view.View.measure(View.java:15364)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4824)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-25 18:24:17.228:E / AndroidRuntime(312):在com.android.internal.policy.impl.PhoneWindow $ DecorView.onMeasure(PhoneWindow.java:2359)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.view.View.measure(View.java:15364)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1974)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1217)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1390)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1110)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:4472)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.view.Choreographer $ CallbackRecord.run(Choreographer.java:725)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.view.Choreographer.doCallbacks(Choreographer.java:555)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.view.Choreographer.doFrame(Choreographer.java:525)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.view.Choreographer $ FrameDisplayEventReceiver.run(Choreographer.java:711)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.os.Handler.handleCallback(Handler.java:615)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.os.Handler.dispatchMessage(Handler.java:92)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.os.Looper.loop(Looper.java:137)
03-25 18:24:17.228:E / AndroidRuntime(312):在android.app.ActivityThread.main(ActivityThread.java:4918)
03-25 18:24:17.228:E / AndroidRuntime(312):在java.lang.reflect.Method.invokeNative(本机方法)
03-25 18:24:17.228:E / AndroidRuntime(312):在java.lang.reflect.Method.invoke(Method.java:511)
03-25 18:24:17.228:E / AndroidRuntime(312):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1004)
03-25 18:24:17.228:E / AndroidRuntime(312):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
03-25 18:24:17.228:E / AndroidRuntime(312):在dalvik.system.NativeStart.main(本机方法)
你有没有解决这个问题呢?您需要初始化的UniversalImageLoader的例子code中的ImageLoader的:
文件cacheDir = StorageUtils.getCacheDirectory(背景);
ImageLoaderConfiguration配置=新ImageLoaderConfiguration.Builder(上下文)
.memoryCacheExtraOptions(480,800)//默认为设备的屏幕尺寸
.discCacheExtraOptions(480,800,COM pressFormat.JPEG,75)
.taskExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
.taskExecutorForCachedImages(AsyncTask.THREAD_POOL_EXECUTOR)
.threadPoolSize(3)//默认
.threadPriority(Thread.NORM_PRIORITY - 1)//默认
.tasksProcessingOrder(QueueProcessingType.FIFO)//默认
.denyCacheImageMultipleSizesInMemory()
.memoryCache(新UsingFreqLimitedMemoryCache(2 * 1024 * 1024))//默认
.memoryCacheSize(2 * 1024 * 1024)
.discCache(新UnlimitedDiscCache(cacheDir))//默认
.discCacheSize(50 * 1024 * 1024)
.discCacheFileCount(100)
.discCacheFileNameGenerator(新的Hash codeFileNameGenerator())//默认
.imageDownloader(新BaseImageDownloader(上下文))//默认
.defaultDisplayImageOptions(DisplayImageOptions.createSimple())//默认
.enableLogging()
。建立();
I want to gridview and listview using Android-Universal-Image-Loader.
https://github.com/nostra13/Android-Universal-Image-Loader
I downloaded and modified it.
it works fine, however when I change and move the source to another project, it's crashed.
I don't know why :(
there is no error and any error messages.
I think it's null point error or initiate library.
I think error will comes with this part.
listView = (GridView) findViewById(R.id.gridview);
((GridView) listView).setAdapter(new ImageAdapter());
and
public class ImageAdapter extends BaseAdapter {
@Override
public int getCount() {
Log.v("OWL","TEST1");
return imageUrls.length;
}
@Override
public Object getItem(int position) {
Log.v("OWL","TEST2");
return null;
}
@Override
public long getItemId(int position) {
Log.v("OWL","TEST3");
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Log.v("OWL","TEST4");
final ImageView imageView;
if (convertView == null) {
imageView = (ImageView) getLayoutInflater().inflate(R.layout.item_grid_image, parent, false);
Log.v("OWL","TEST5");
} else {
imageView = (ImageView) convertView;
Log.v("OWL","TEST6");
}
imageLoader.displayImage(imageUrls[position], imageView, options);
Log.v("OWL","TEST7");
return imageView;
}
}
I cannot see TEST6, TEST7 on the LOGCAT
I attached log blow. please help me or let't me know how to use that library.
03-25 18:24:17.208: D/AndroidRuntime(312): Shutting down VM
03-25 18:24:17.208: W/dalvikvm(312): threadid=1: thread exiting with uncaught exception (group=0x41693438)
03-25 18:24:17.228: E/AndroidRuntime(312): FATAL EXCEPTION: main
03-25 18:24:17.228: E/AndroidRuntime(312): java.lang.IllegalStateException: ImageLoader must be init with configuration before using
03-25 18:24:17.228: E/AndroidRuntime(312): at com.nostra13.universalimageloader.core.ImageLoader.checkConfiguration(ImageLoader.java:359)
03-25 18:24:17.228: E/AndroidRuntime(312): at com.nostra13.universalimageloader.core.ImageLoader.displayImage(ImageLoader.java:200)
03-25 18:24:17.228: E/AndroidRuntime(312): at com.nostra13.universalimageloader.core.ImageLoader.displayImage(ImageLoader.java:162)
03-25 18:24:17.228: E/AndroidRuntime(312): at com.kmob.camera.ImageGridActivity$ImageAdapter.getView(ImageGridActivity.java:117)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.widget.AbsListView.obtainView(AbsListView.java:2449)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.widget.GridView.onMeasure(GridView.java:1030)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.view.View.measure(View.java:15364)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:617)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:399)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.view.View.measure(View.java:15364)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4824)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.view.View.measure(View.java:15364)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4824)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1396)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.widget.LinearLayout.measureVertical(LinearLayout.java:681)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.widget.LinearLayout.onMeasure(LinearLayout.java:574)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.view.View.measure(View.java:15364)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4824)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-25 18:24:17.228: E/AndroidRuntime(312): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2359)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.view.View.measure(View.java:15364)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1974)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1217)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1390)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1110)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4472)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.view.Choreographer.doFrame(Choreographer.java:525)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.os.Handler.handleCallback(Handler.java:615)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.os.Handler.dispatchMessage(Handler.java:92)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.os.Looper.loop(Looper.java:137)
03-25 18:24:17.228: E/AndroidRuntime(312): at android.app.ActivityThread.main(ActivityThread.java:4918)
03-25 18:24:17.228: E/AndroidRuntime(312): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 18:24:17.228: E/AndroidRuntime(312): at java.lang.reflect.Method.invoke(Method.java:511)
03-25 18:24:17.228: E/AndroidRuntime(312): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
03-25 18:24:17.228: E/AndroidRuntime(312): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
03-25 18:24:17.228: E/AndroidRuntime(312): at dalvik.system.NativeStart.main(Native Method)
Did you resolve this problem? You need to initialize the imageLoader with the example code on the UniversalImageLoader:
File cacheDir = StorageUtils.getCacheDirectory(context);
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
.memoryCacheExtraOptions(480, 800) // default = device screen dimensions
.discCacheExtraOptions(480, 800, CompressFormat.JPEG, 75)
.taskExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
.taskExecutorForCachedImages(AsyncTask.THREAD_POOL_EXECUTOR)
.threadPoolSize(3) // default
.threadPriority(Thread.NORM_PRIORITY - 1) // default
.tasksProcessingOrder(QueueProcessingType.FIFO) // default
.denyCacheImageMultipleSizesInMemory()
.memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024)) // default
.memoryCacheSize(2 * 1024 * 1024)
.discCache(new UnlimitedDiscCache(cacheDir)) // default
.discCacheSize(50 * 1024 * 1024)
.discCacheFileCount(100)
.discCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
.imageDownloader(new BaseImageDownloader(context)) // default
.defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // default
.enableLogging()
.build();
这篇关于如何使用" Android的通用 - 图像 - 装载机"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!