Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android中的gridview图像库_Android_Gridview_Gallery - Fatal编程技术网

android中的gridview图像库

android中的gridview图像库,android,gridview,gallery,Android,Gridview,Gallery,您好,我在本教程中创建了一个具有栅格视图的图像库 我将70个图像添加到ImageAdapter.java,然后运行应用程序并强制关闭 09-08 20:24:29.242:D/dalvikvm(4971):GC_EXTERNAL_ALLOC freed您的图像大小太大。请使用低维图像。使用低维图像不要一次加载70个图像,使用延迟加载图像,尤其是使用低维图像。png图像 不要一次加载70个图像,使用延迟加载加载图像,也要使用低维图像,尤其是.png图像 Q1:它说:java.lang.OutOf

您好,我在本教程中创建了一个具有栅格视图的图像库

我将70个图像添加到ImageAdapter.java,然后运行应用程序并强制关闭


09-08 20:24:29.242:D/dalvikvm(4971):GC_EXTERNAL_ALLOC freed您的图像大小太大。请使用低维图像。使用低维图像不要一次加载70个图像,使用
延迟加载图像,尤其是使用低维图像。png图像

不要一次加载70个图像,使用
延迟加载加载图像
,也要使用低维图像,尤其是.png图像

Q1:它说:
java.lang.OutOfMemoryError:位图大小超过VM预算

这意味着你试图加载一个太大的图像。它不能保存在VM堆内存中


Q2:请参阅:

Q1:它显示:
java.lang.OutOfMemoryError:位图大小超过VM预算

这意味着你试图加载一个太大的图像。它不能保存在VM堆内存中


问题2:请参阅:

我的ImageGallery库使用起来非常简单。这可能是你需要的

Intent Intent=新的Intent(MainActivity.this、ImageGalleryActivity.class);
ArrayList images=新的ArrayList();
图片。添加(“https://images.unsplash.com/photo-1437422061949-f6efbde0a471?q=80&fm=jpg&s=e23055c9ba7686b8fe583fb8318a1f88");
图片。添加(“https://images.unsplash.com/photo-1434139240289-56c519f77cb0?q=80&fm=jpg&s=13f8a0d1c2f96b5f311dedeb17cddb60");
图片。添加(“https://images.unsplash.com/photo-1429152937938-07b5f2828cdd?q=80&fm=jpg&s=a4f424db0ae5a398297df5ae5e0520d6");
图片。添加(“https://images.unsplash.com/photo-1430866880825-336a7d7814eb?q=80&fm=jpg&s=450de8563ac041f48b1563b499f56895");
图片。添加(“https://images.unsplash.com/photo-1429547584745-d8bec594c82e?q=80&fm=jpg&s=e9a7d9973088122a3e453cb2af541201");
图片。添加(“https://images.unsplash.com/photo-1429277158984-614d155e0017?q=80&fm=jpg&s=138f154e17a304b296c953323862633b");
图片。添加(“https://images.unsplash.com/photo-1429042007245-890c9e2603af?q=80&fm=jpg&s=8b76d20174cf46bffe32ea18f05551d3");
图片。添加(“https://images.unsplash.com/photo-1429091967365-492aaa5accfe?q=80&fm=jpg&s=b7430cfe5508430aea39fcf3b0645878");
图片。添加(“https://images.unsplash.com/photo-1430132594682-16e1185b17c5?q=80&fm=jpg&s=a70abbfff85382d11b03b9bbc71649c3");
图片。添加(“https://images.unsplash.com/photo-1436891620584-47fd0e565afb?q=80&fm=jpg&s=33cf5b0ee9fbd292475a0c03bee481c9");
intent.putStringArrayListExtra(“图像”,图像);
//可以选择使用调色板设置背景色
intent.putExtra(“调色板颜色类型”,PaletteColorType.VIBRANT);
星触觉(意向);

我的ImageGallery库使用起来非常简单。这可能是你需要的

Intent Intent=新的Intent(MainActivity.this、ImageGalleryActivity.class);
ArrayList images=新的ArrayList();
图片。添加(“https://images.unsplash.com/photo-1437422061949-f6efbde0a471?q=80&fm=jpg&s=e23055c9ba7686b8fe583fb8318a1f88");
图片。添加(“https://images.unsplash.com/photo-1434139240289-56c519f77cb0?q=80&fm=jpg&s=13f8a0d1c2f96b5f311dedeb17cddb60");
图片。添加(“https://images.unsplash.com/photo-1429152937938-07b5f2828cdd?q=80&fm=jpg&s=a4f424db0ae5a398297df5ae5e0520d6");
图片。添加(“https://images.unsplash.com/photo-1430866880825-336a7d7814eb?q=80&fm=jpg&s=450de8563ac041f48b1563b499f56895");
图片。添加(“https://images.unsplash.com/photo-1429547584745-d8bec594c82e?q=80&fm=jpg&s=e9a7d9973088122a3e453cb2af541201");
图片。添加(“https://images.unsplash.com/photo-1429277158984-614d155e0017?q=80&fm=jpg&s=138f154e17a304b296c953323862633b");
图片。添加(“https://images.unsplash.com/photo-1429042007245-890c9e2603af?q=80&fm=jpg&s=8b76d20174cf46bffe32ea18f05551d3");
图片。添加(“https://images.unsplash.com/photo-1429091967365-492aaa5accfe?q=80&fm=jpg&s=b7430cfe5508430aea39fcf3b0645878");
图片。添加(“https://images.unsplash.com/photo-1430132594682-16e1185b17c5?q=80&fm=jpg&s=a70abbfff85382d11b03b9bbc71649c3");
图片。添加(“https://images.unsplash.com/photo-1436891620584-47fd0e565afb?q=80&fm=jpg&s=33cf5b0ee9fbd292475a0c03bee481c9");
intent.putStringArrayListExtra(“图像”,图像);
//可以选择使用调色板设置背景色
intent.putExtra(“调色板颜色类型”,PaletteColorType.VIBRANT);
星触觉(意向);
  • 打开您的AndroidManifest.xml文件
  • 查找
    标记
  • 将以下属性添加到
    标记中
  • 只需复制属性。。。
  • 打开您的AndroidManifest.xml文件
  • 查找
    标记
  • 将以下属性添加到
    标记中

  • 只需复制属性……Q1:它说:
    java.lang.OutOfMemoryError:位图大小超过VM预算
    这是什么?我的内存有问题还是我的应用程序有问题?你试图加载的图像太大了。它不能保存在VM堆内存中。Q2:请参阅:Q1:它说:
    java.lang.OutOfMemoryError:位图大小超过VM预算
    这是什么?我的内存有问题还是我的应用程序有问题?你试图加载的图像太大了。它无法保存在VM堆内存中。问题2:请参阅:
    09-08 20:24:29.242: D/dalvikvm(4971): GC_EXTERNAL_ALLOC freed <1K, 48% free   2818K/5379K, external 59477K/61525K, paused 26ms
    09-08 20:24:29.250: E/dalvikvm-heap(4971): 1638400-byte external allocation too large for this process.
    09-08 20:24:29.281: I/dalvikvm-heap(4971): Clamp target GC heap from 65.182MB to 64.000MB
    09-08 20:24:29.281: D/dalvikvm(4971): GC_FOR_MALLOC freed 0K, 48% free 2818K/5379K, external 59477K/61525K, paused 20ms
    09-08 20:24:29.289: E/GraphicsJNI(4971): VM won't let us allocate 1638400 bytes
    09-08 20:24:29.289: D/skia(4971): --- decoder->decode returned false
    09-08 20:24:29.312: W/dalvikvm(4971): threadid=1: thread exiting with uncaught exception (group=0x40015578)
    09-08 20:24:29.398: E/AndroidRuntime(4971): FATAL EXCEPTION: main
    09-08 20:24:29.398: E/AndroidRuntime(4971): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:563)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:439)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.content.res.Resources.loadDrawable(Resources.java:1709)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.content.res.Resources.getDrawable(Resources.java:581)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.widget.ImageView.resolveUri(ImageView.java:501)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.widget.ImageView.setImageResource(ImageView.java:280)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at com.example.androidhive.ImageAdapter.getView(ImageAdapter.java:110)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.widget.AbsListView.obtainView(AbsListView.java:1567)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.widget.GridView.makeAndAddView(GridView.java:1254)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.widget.GridView.makeRow(GridView.java:300)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.widget.GridView.fillDown(GridView.java:253)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.widget.GridView.fillGap(GridView.java:220)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.widget.AbsListView.trackMotionScroll(AbsListView.java:4132)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.widget.AbsListView.onTouchEvent(AbsListView.java:2588)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.view.View.dispatchTouchEvent(View.java:3938)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1733)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1151)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1717)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2215)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1886)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.os.Handler.dispatchMessage(Handler.java:99)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.os.Looper.loop(Looper.java:130)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at android.app.ActivityThread.main(ActivityThread.java:3689)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at java.lang.reflect.Method.invokeNative(Native Method)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at java.lang.reflect.Method.invoke(Method.java:507)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
    09-08 20:24:29.398: E/AndroidRuntime(4971):     at dalvik.system.NativeStart.main(Native Method)
    
    Intent intent = new Intent(MainActivity.this, ImageGalleryActivity.class);
    
    ArrayList<String> images = new ArrayList<>();
    
    images.add("https://images.unsplash.com/photo-1437422061949-f6efbde0a471?q=80&fm=jpg&s=e23055c9ba7686b8fe583fb8318a1f88");
    images.add("https://images.unsplash.com/photo-1434139240289-56c519f77cb0?q=80&fm=jpg&s=13f8a0d1c2f96b5f311dedeb17cddb60");
    images.add("https://images.unsplash.com/photo-1429152937938-07b5f2828cdd?q=80&fm=jpg&s=a4f424db0ae5a398297df5ae5e0520d6");
    images.add("https://images.unsplash.com/photo-1430866880825-336a7d7814eb?q=80&fm=jpg&s=450de8563ac041f48b1563b499f56895");
    images.add("https://images.unsplash.com/photo-1429547584745-d8bec594c82e?q=80&fm=jpg&s=e9a7d9973088122a3e453cb2af541201");
    images.add("https://images.unsplash.com/photo-1429277158984-614d155e0017?q=80&fm=jpg&s=138f154e17a304b296c953323862633b");
    images.add("https://images.unsplash.com/photo-1429042007245-890c9e2603af?q=80&fm=jpg&s=8b76d20174cf46bffe32ea18f05551d3");
    images.add("https://images.unsplash.com/photo-1429091967365-492aaa5accfe?q=80&fm=jpg&s=b7430cfe5508430aea39fcf3b0645878");
    images.add("https://images.unsplash.com/photo-1430132594682-16e1185b17c5?q=80&fm=jpg&s=a70abbfff85382d11b03b9bbc71649c3");
    images.add("https://images.unsplash.com/photo-1436891620584-47fd0e565afb?q=80&fm=jpg&s=33cf5b0ee9fbd292475a0c03bee481c9");
    
    intent.putStringArrayListExtra("images", images);
    // optionally set background color using Palette
    intent.putExtra("palette_color_type", PaletteColorType.VIBRANT);
    
    startActivity(intent);