我想在幻燈片上制作具有不同圖像的應用程序,我的代碼如下: @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
提交
取消