out of memory with image switcher android -


Let's see how this issue can be understood. I have 4 activities and 1 layout. The layout includes an image switcher and a gallery. These activities show different images that I have in the integer array. All these images are in the drawing folder when I start the application. Everything is fine, I can switch between activities. , But after some time when I scroll the gallery, then the memory exception goes out. I do not know how to solve it because I do not know that Where is to see, there is no stack trace, the only thing I get is: <3> 3-16 15: 46: 50.367: error / lightweight pile (23389): 8479 9 2- Bite exterior process is very large for this process. 03-16 15: 46: 50.367: Error / DelWiki (23389): Out of memory: heap size = 5255 KB, allocated = 2833 KB, bitmap size = 18 9 00 KB 03-16 15: 46: 50.367: error / GraphicsJNI (23389): VM will not allow us to allocate 8479 9 byte

and here is the code I am using:

  Private ImageSwitter mSwitcher; Private integer [] mThumbIds = {drawals here ...}; Override public null on @reate (bundle saved instainstate) {super.naught (savedinstenstate); MSwitcher = (ImageSwitcher) Search ViewById (R.id.switcher); MSwitcher.setFactory (this); MSwitcher.setInAnimation (AnimationUtils.loadAnimation (this, android.r.anim.fade_in)); MSwitcher.setOutAnimation (animationualloadload animation (this, android.r.anim.fade_out)); Gallery G = (Gallery) ViewById (R.id.gallery); G.setAdapter (new basics adapter (getApplicationContext), MTHmbS); G.setOnItemSelectedListener (this); } Selected items on public zeros (adapterview & lt;? & Gt; parent, see v, int position, long id) {mSwitcher.setImageResource (mThumbIds [position]); } None of the public zeros selected (adapter view & lt ;? & gt; parent) {} Make public view () {ImageView i = New ImageView (this); I.setBackgroundColor (0xFF000000); I.setScaleType (ImageView.ScaleType.FIT_CENTER); I.setLayoutParams (New ImageSwitcher.LayoutParams (Layout Paramount. MATCH_PARENT, Layouts Para MATCH_PARENT)); Return i; }    This is my adapter class:   
  public view getView (see the status of int, seeviewview, view group guardian) {ImageView I = new imageview (mContext); I.setImageResource (mThumbIds [status]); I.setAdjustViewBounds (true); I.setLayoutParams (New Gallery. Layout side (layout perm. WRAP_CONTENT, layout para. WRAP_CONTENT)); I.setBackgroundResource (R.drawable.i); Return i; }   

I do not know how to clean the heap, nor is the memory still running when dashing from previous activity

< Div class = "post-text" itemprop = "text">

Can you solve this problem? Every time you see a different image, you are required to use recycled scenes to get a new ImageView GetView method for running out of memory. getView (see int status, see conversion, ViewGroup parent) {if (convertView == null) {// Create new view convert = View imageView (mContext); ConvertView.setAdjustViewBounds (true); ConvertViewset layoutPar (new gallery layoutpad (layout perm. WRAP_CONTENT, layout para. WRAP_CONTENT)); ConvertView.setBackgroundResource (R.drawable.i); } ImageView iv = (ImageView) Convertview; Iv.setImageResource (mThumbIds [status]); Return Convertview; }

Comments