我想在幻灯片上制作具有不同图像的应用程序,我的代码如下: @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">
添加回答
举报
0/150
提交
取消
