Thanks for helping Romain! I get an OutOfMemoryError on getDrawable(R.drawable.largeimage)
On Dec 22, 5:59 pm, Romain Guy <[email protected]> wrote: > What is the crash exactly? What do you see in the logs? It sounds like > you're having an OutOfMemory situation. > > > > On Mon, Dec 22, 2008 at 12:53 PM, mattsm8 <[email protected]> wrote: > > > I am trying to create an application which will display an image which > > is larger than the screen of the device where the user can scroll > > around to see different parts of the picture. This all works fine > > until I open or close the keyboard on my G1 whereupon the application > > crashes. Funnily enough it does not crash if only the orientation is > > changed without opening or closing the keyboard. I reduced the > > application to the bare minimum to try to see if I could work around > > it in some way but it seems that as soon as I create an ImageView with > > a large picture the memory is never released, even if I dereference > > the ImageView object. Clearly there is something essential that I > > don't understand here, could someone help, please? > > > A stripped down version of my app is below. I have created a standard > > android application in Eclipse and modified the java file as below. > > The drawable largeimage is a png file of 1.3mb. > > > package com.mattsm8.android.imagetest; > > > import android.app.Activity; > > import android.os.Bundle; > > import android.widget.ImageView; > > > public class ImageTest extends Activity { > > ImageView iv = null; > > �...@override > > public void onCreate(Bundle savedInstanceState) { > > super.onCreate(savedInstanceState); > > iv = new ImageView(this); > > setContentView(iv); > > iv.setImageDrawable(iv.getResources().getDrawable > > (R.drawable.largeimage)); > > setContentView(R.layout.main); > > iv = null; > > } > > } > > -- > Romain Guy > Android framework engineer > [email protected] > > Note: please don't send private questions to me, as I don't have time > to provide private support. All such questions should be posted on > public forums, where I and others can see and answer them --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

