Я хочу создать приложение с другим изображением на слайд-шоу, и мой код ниже :
@NonNull
@Override
public 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">