我显示150+在viewpager图像,当页面尺寸越过70应用程序崩溃, 所有图像都从网络加载,和我休耕[链接]:Android:奇怪的内存不足问题
i am showing 150+ images in viewpager, when page size crossed 70 app is crashing , all images are loading from network , and i have fallowed [link]: Android: Strange out of memory issue
和我是回收它时,页面刷卡达到4,
and i am recycling it whenever page swiping reaches 4,
70页的应用程序采取的内存200 MB。
for 70 page app taking 200 MB of memory.
我需要你的帮助,如何处理它
i need help from you, how to handle it
我要显示所有网页与刷卡......
i have to show all pages with swiping...
我也用调用Runtime.getRuntime()GC();
i have also used Runtime.getRuntime().gc();
是没有办法释放内存,如果应用程序内存达到50+ MB
is any way to releasing memory if app memory is reaches the 50+ MB
在此先感谢
完整的解决方案可以在下面找到,重要的线是那些在destroyItem方式:
The complete solution can be found below, the important lines are those in the destroyItem method:
private class ContentPagerAdapter extends PagerAdapter {
@Override
public void destroyItem(View collection, int position, Object o) {
View view = (View)o;
((ViewPager) collection).removeView(view);
view = null;
}
@Override
public void finishUpdate(View arg0) {
// TODO Auto-generated method stub
}
@Override
public int getCount() {
return ids.length;
}
@Override
public Object instantiateItem(View context, int position) {
ImageView imageView = new ImageView(getApplicationContext());
imageView.findViewById(R.id.item_image);
imageView.setImageBitmap(BitmapFactory.decodeResource(getResources(), ids[position]));
((ViewPager) context).addView(imageView);
return imageView;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view==((ImageView)object);
}
@Override
public void restoreState(Parcelable arg0, ClassLoader arg1) {
// TODO Auto-generated method stub
}
@Override
public Parcelable saveState() {
// TODO Auto-generated method stub
return null;
}
@Override
public void startUpdate(View arg0) {
// TODO Auto-generated method stub
}