Android Question Scrollable List - Size Limits

Lakhtin_V

Active Member
Licensed User
Longtime User
I am trying to visualize the spectrogram of a sound fragment. I am using a vertical scroll area, with panels as rows. On the panels are labels. When I had a maximum of 200-300 lines in the list, I did not have problems. About 30 lines fit on the screen at a time. But when the number of lines reached 1000 or more, an error began to appear.
Error:
** Activity (spectrnorm) Resume **
java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 751464 bytes
    at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3991)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6550)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:857)
Caused by: android.os.TransactionTooLargeException: data parcel size 751464 bytes
    at android.os.BinderProxy.transactNative(Native Method)
    at android.os.BinderProxy.transact(Binder.java:764)
    at android.app.IActivityManager$Stub$Proxy.activityStopped(IActivityManager.java:4649)
    at android.app.ActivityThread$StopInfo.run(ActivityThread.java:3975)
    ... 7 more
I think this is due to some limitations. How can I solve this problem. Maybe I'm not initializing the scroll area correctly at the very beginning, I don't understand well what parameter needs to be set at the time of initialization.
Initialize:
    Dim scvS as ScrollView
....
    scvS.Initialize(50000)
    Activity.AddView(scvS, 0%x, 11%y, 100%x, 82%y)
    PanelS=scvS.Panel
....
    For z=0 To Nlst-1
        panel0.Initialize("")
        panel0.Height=PH
        panel0.Width=PanelWidth
        panel0.Color=Colors.White
....
        panel0.addView(Lbl,0,0,10%x,3%y)
 
Solution
Lazy loading, also known as on-demand loading.
Instead of loading an entire views all at once, lazy loading loads only the parts that are immediately necessary.
The remaining content is loaded later, as the user interacts with the page.
Advantages of Lazy Loading are reducing memory usage and imporving performace.
Here is a tutorial about lzay loading

Lakhtin_V

Active Member
Licensed User
Longtime User
This error happens when you switch apps and there are many views in the activity. The problem isn't in ScrollView itself.

The solution is to switch to "lazy loading" or in this case, remove the old items when you add new ones.
I don't understand the term "Lazy loading" yet.
My intuition told me that the problem is that a lot of elements are created inside the scroll area of about 500 x 12. Maybe there is some library or special tool that can display my long colored "patchwork carpet". My goal is to display a lot of colored labels and I don't want to sacrifice the number of lines. What number of elements in an activity is critical. Is there some specific limitation on the number that I should take into account and not exceed it?
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Lazy loading, also known as on-demand loading.
Instead of loading an entire views all at once, lazy loading loads only the parts that are immediately necessary.
The remaining content is loaded later, as the user interacts with the page.
Advantages of Lazy Loading are reducing memory usage and imporving performace.
Here is a tutorial about lzay loading
 
Upvote 1
Solution

Lakhtin_V

Active Member
Licensed User
Longtime User
Interesting observation, I use two different activities. In one, all labels are of the same color and there is no failure from overflow. In the other activity, the same number of elements and rows, but it has multi-colored labels and it is in this activity that the overflow problem occurs. Therefore, I think that the process of coloring the labels may be the cause of the failure.
 
Upvote 0

Lakhtin_V

Active Member
Licensed User
Longtime User
Good advice, I will definitely use it.
 
Upvote 0

Lakhtin_V

Active Member
Licensed User
Longtime User
This error happens when you switch apps and there are many views in the activity. The problem isn't in ScrollView itself.

The solution is to switch to "lazy loading" or in this case, remove the old items when you add new ones.
I tested my application on different devices. On the old Samsung tablet I managed to work 600 lines without failure with the same waiting time. And on the new powerful Chinese one the limit was 390 lines... I conclude that this is more of a hardware problem or Android versions. But it doesn't look like a B4A problem.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…