0

Sorry if this sound newb but.. =[

Im working with an application which need to load a large amount of images onto a textview, i didnt use webview becuz sometimes it doesnt lead to mobile view so i decide to parse the content and use html.fromHtml to show it to the Textview.

Problem is: if i load a page is luckily there not much images, it run pretty smooth. otherwise it get the error like below...

anyone know if theres a way that i can dispose the source from the system memory after it finished reading the image?...or...any other way will fix my problem?

i used the source from here Android ImageGetter images overlapping text

    05-08 21:30:31.404: ERROR/dalvikvm-heap(25083): Out of memory on a 1920016-byte allocation.
    05-08 21:30:31.404: ERROR/AndroidRuntime(25083): FATAL EXCEPTION: AsyncTask #10
    java.lang.RuntimeException: An error occured while executing doInBackground()
    at android.os.AsyncTask$3.done(AsyncTask.java:299)
    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
    at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
    at java.lang.Thread.run(Thread.java:856)
    Caused by: java.lang.OutOfMemoryError
    at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
    at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:527)
    at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:353)
    at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:781)
    at android.graphics.drawable.Drawable.createFromStream(Drawable.java:741)
    at com.vilalab.five.model.URLImageParser$ImageGetterAsyncTask.fetchDrawable(URLImageParser.java:90)
    at com.vilalab.five.model.URLImageParser$ImageGetterAsyncTask.doInBackground(URLImageParser.java:58)
    at com.vilalab.five.model.URLImageParser$ImageGetterAsyncTask.doInBackground(URLImageParser.java:48)
    at android.os.AsyncTask$2.call(AsyncTask.java:287)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
    ... 4 more
   05-08 21:30:31.504: ERROR/dalvikvm-heap(25083): Out of memory on a 1920016-byte allocation.
4

1 回答 1

0

查看这篇文章,它使用从 SD 卡/图库中获取图片的示例来了解如何对图像进行下采样,从而避免此问题。这是一个很容易解决的问题。

于 2013-05-08T14:57:33.653 回答