为了账号安全,请及时绑定邮箱和手机立即绑定

带有多个图像的幻灯片放映?

带有多个图像的幻灯片放映?

慕容708150 2022-07-20 15:48:10
我想在幻灯片上制作具有不同图像的应用程序,我的代码如下:    @NonNull@Overridepublic Object instantiateItem(@NonNull ViewGroup container, int position) {    inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);    View view = inflater.inflate(R.layout.swipe, container, false);    ImageView imageView = view.findViewById(R.id.swipe_imageView);    TextView textView = view.findViewById(R.id.swipe_textView);    if (CustomAdapterList.titleForOther.equalsIgnoreCase("Vers la lune"))    {        imageView.setImageResource(vers[position]);    }    else {        imageView.setBackgroundResource(image[position]);    }    textView.setText(CustomAdapterList.titleForOther + "");    container.addView(view);    return view;}当我运行我的应用程序并单击“Vers la lune”标题时,我的应用程序崩溃并出现错误:java.lang.OutOfMemoryError: Failed to allocate a 298650252 byte allocation with 12571136 free bytes and 238MB until OOM    at dalvik.system.VMRuntime.newNonMovableArray(Native Method)错误来自这一行:imageView.setImageResource(vers[position]);我的清单代码如下:<application    android:allowBackup="true"    android:hardwareAccelerated="false"    android:icon="@mipmap/ic_launcher"    android:label="@string/app_name"    android:roundIcon="@mipmap/ic_launcher_round"    android:supportsRtl="false"    android:theme="@style/AppTheme"    android:largeHeap="true">
查看完整描述

1 回答

?
陪伴而非守候

TA贡献1757条经验 获得超8个赞

这可能会奏效。添加这个

 android:largeHeap="true"

在您的 Manifest.xml 文件中。在应用程序标签中。


查看完整回答
反对 回复 2022-07-20
  • 1 回答
  • 0 关注
  • 129 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号