イメージスライダーを作成していますが、これは何とか私が使用している画像のために起こることが分かっていました。私は試しましたが、android:largeHeap="true"
があります。Java.lang.outofメモリエラー
は画像
public class EsquireAdapter extends PagerAdapter {
private int [] imgs = { R.drawable.conf4,R.drawable.food,R.drawable.food1,R.drawable.food2,R.drawable.conf4,R.drawable.food,R.drawable.food1,R.drawable.food2,R.drawable.escalope,};
private LayoutInflater inflater;
private Context ctxt;
public EsquireAdapter(Context ctxt) {
this.ctxt = ctxt;
}
@Override
public int getCount() {
return imgs.length;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
inflater = (LayoutInflater)ctxt.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.swipee,container,false);
ImageView img = (ImageView)v.findViewById(R.id.ImageView);
TextView tv = (TextView)v.findViewById(R.id.textView);
img.setImageResource(imgs[position]);
container.addView(v);
return v;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.invalidate();
}
}
を出力し、ここで私のlogcatである私のアダプターのコードです:
FATAL EXCEPTION: main Process: com.example.moses.ngongapp, PID: 21333 java.lang.OutOfMemoryError: Failed to allocate a 144764940 byte allocation with 16777120 free bytes and 27MB until OOM at dalvik.system.VMRuntime.newNonMovableArray(Native Method) at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:609)
を動作するかどうか私に教えてください。ヒープダンプを生成し、メモリをどこで使用しているのかを確認してください。 –
Plzアクティビティコードを追加してください。 –
リストビューでdrawableが多すぎます。この問題が発生したのはなぜですか。 – Noorul