Android Question CustomListView and Canvas

Marek Brezina

Member
Licensed User
Hello,

I use CustomListView control. I need insert text, images, rectangle in each item (each ListView item contains different elements and different count). I used Canvas and Draw methods. But when ListView contains more items, then application generates a memory allocation error. See. attachment. How can I solve this?

Thanks for any advice.

Marek
 

Attachments

  • error.png
    error.png
    54.6 KB · Views: 259
  • example.zip
    12.2 KB · Views: 237

Marek Brezina

Member
Licensed User
LogCat connected to: 925db4c3
--------- beginning of crash
--------- beginning of system
--------- beginning of main
** Activity (main) Create, isFirst = true **
Class not found: anywheresoftware.b4a.samples.customlistview.customlistview, trying: cz.example.listview.customlistview
main_adduseritem (java line: 388)
java.lang.OutOfMemoryError: Failed to allocate a 579852 byte allocation with 171432 free bytes and 167KB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:831)
at android.graphics.Bitmap.createBitmap(Bitmap.java:808)
at android.graphics.Bitmap.createBitmap(Bitmap.java:775)
at anywheresoftware.b4a.objects.drawable.CanvasWrapper.Initialize(CanvasWrapper.java:76)
at cz.example.listview.main._adduseritem(main.java:388)
at cz.example.listview.main._activity_create(main.java:343)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:179)
at cz.example.listview.main.afterFirstLayout(main.java:102)
at cz.example.listview.main.access$000(main.java:17)
at cz.example.listview.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
 
Upvote 0
Top