Problem mit Listview

D

Deleted member 103

Guest
Hallo,

was kann ich machen damit das Listview nicht nach eine Orientation änderung nochmal komplett gefüllt wird?
Ich möchte nur das die vorher geladene Einträge nochmal dargestellt werden, ohne das die "Sub Activity_Create" nochmal ausgeführt wird.

PS. ich hoffe das Google es richtig übersetzt hat.


Hi,

is what I can to not make the list view for a change of orientation again completely filled?
I only want the the loaded items are presented again, is without the "Sub Activity_Create" running again.

PS. I hope Google has translated it correctly.


Ciao,
Filippo
 

Attachments

  • Listview_20101229.zip
    16.1 KB · Views: 221
D

Deleted member 103

Guest
Ja, in dem "Sub Aktivity_Create" wird das Listview vor dem füllen gelöscht.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I'm afraid that you must fill the ListView again after an orientation change.
I tryed in the emulator with 2 ListViews, one filled normaly and the second one only if FirstTime = True.
But after an orientation change the second ListView is no more displayed.

Best regards.

Ich befürchte dass Du das ListView nach einer Orientierungsänderung neu füllen musst.
Ich habe im Emulator mit 2 ListViews versucht, das eine normal gefüllt, und das 2te nur wenn FirstTime = True.
Leider wird nach einer Orientierungsänderung das 2te ListView nich mehr angezeigt.

Beste Grüsse.
 
Upvote 0
D

Deleted member 103

Guest
@Klaus
Ich befürchte dass Du das ListView nach einer Orientierungsänderung neu füllen musst.
Das ist aber sehr schlecht!
In mein Fall werden die Einträge(momentan ca. 800) von eine Datenbank gelesen und es dauert, selbst auf dem Device, sehr lang(ca. 15sec).
Es kann doch nicht sein das nach eine Orientierungsänderung das ListView nochmal gefüllt werden muss, es muss doch noch eine andere Lösung geben.
Beim "eclipse" wird das ListView, nach einer Orientierungsänderung, nicht nochmal gefüllt.

But this is very bad!
In my case, the entries (currently 800) is read from a database and it will take, even on the device, very long (about 15 seconds).
It can not be the be filled again after a policy change, the list view must be, there must be yet another solution.
The "eclipse", the list view, after a change in orientation, not filled again.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
There is no need to read the items from the database every time.
You can create a process global List (not ListView). When FirstTime = True load read the items from the db and store them in the list.
Then add the items from the List to the ListView.

15 seconds seems to be too slow for reading 800 items from SQLite.
 
Upvote 0
D

Deleted member 103

Guest
@Erel
Please look at my example.
 

Attachments

  • Listview_20101229_2.zip
    16.2 KB · Views: 257
Upvote 0

klaus

Expert
Licensed User
Longtime User
The problem is the DoEvents in the For/Next loop to load the ListView.
It takes 110 seconds in the emulator

Removing the DoEvents, it takes about 5-6 seconds, still in the emulator.

But at the first orientation change the program crashes with the message below. 'Sudden stop of the program'. It works OK with 400 samples instead of the 800.

Adding a DoEvents just before the For/Next loop solved the problem.

Attached the new version, with the global List suggested by Erel.

Best regards.
 

Attachments

  • Listview_20101231.zip
    16.4 KB · Views: 239
  • Error.jpg
    Error.jpg
    17.1 KB · Views: 227
Upvote 0

agraham

Expert
Licensed User
Longtime User
The app is dying on my phone with an out of memory problem because it is trying to allocate too much memory to bitmaps and is failing. Each bitmap is 23.4 Kilobytes so 800 of them is a whopping 18.7 Megabytes!

E/dalvikvm-heap( 9992* 9992): 23400-byte external allocation too large for this process.
E/dalvikvm-heap( 9992* 9992): export hprof info for pid: 9992
W/dalvikvm( 9992* 9992): threadid=3: thread exiting with uncaught exception (group=0x2aaca228)
E/AndroidRuntime( 9992* 9992): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 9992* 9992): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
E/AndroidRuntime( 9992* 9992): at android.graphics.Bitmap.nativeCreate(Native Method)
E/AndroidRuntime( 9992* 9992): at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
E/AndroidRuntime( 9992* 9992): at anywheresoftware.b4a.objects.drawable.CanvasWrapper.Initialize(CanvasWrapper.java:64)
 
Upvote 0
D

Deleted member 103

Guest
@Klaus
vielen Dank für deine Hilfe.
Das "List" löst aber, in mein fall, nicht mein Problem. Ich brauche eine lösung damit, bei eine Orientierungsänderung, nicht nochmal der "Sub Aktivity_Create" ausgeführt wird wie in "eclipse".

Removing the DoEvents, it takes about 5-6 seconds, still in the emulator.
Das aber "DoEvents" so viel Zeit/CPU für sich beansprucht ist der Hammer.


Thank you for your help.
The "List" triggers but, in my case, not my problem. I need a solution so that, when a policy change that will not run again the "Sub Aktivity_Create"as in "eclipse ".

Removing the DoEvents, it takes about 5-6 seconds, still in the emulator.
But the "DoEvents" so much time / CPU has claimed the hammer.


@agraham
The app is dying on my phone with an out of memory problem because it is trying to allocate too much memory to bitmaps and is failing. Each bitmap is 23.4 Kilobytes so 800 of them is a whopping 18.7 Megabytes!
This is not in as bad in my Desire is enough memory.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I compared the 110 seconds with the DoEvents in the For/Next loop
to 5-6 seconds without the DoEvents in the For/Next loop.
Both times in the emulator.

I suppose that on the device there should also be a big speed increase.

I knew that the global List doesn't bring a lot because almost all time is spent to load the ListView.

Best regards.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I haven't followed all this thread so I may be off here...
ListView is usually very fast and can support huge number of items. It does it by reusing existing views. So while there can be thousands (or more) items, only about 10 views will be created.
Creating a bitmap for each item is not a good approach and will only work with short lists.
 
Upvote 0
Top