Android Question How to jump to the bottom of Scrollview?

FrankBerra

Active Member
Licensed User
Longtime User
Hi all,
i am trying to scroll to the bottom of a scrollview with the following codes:
B4X:
SuperScrollview.ScrollPosition = SuperScrollview.Panel.Height
or
B4X:
SuperScrollview.FullScroll(true)
or
B4X:
Dim r As Reflector
r.Target = SuperScrollview
r.RunMethod3("scrollTo", 0, "java.lang.int", SuperScrollview.Panel.Height, "java.lang.int")


But nothing happens.

The SuperScrollview is created into the Designer.
To add elements to the scrollview programmatically i have to write something like
B4X:
SuperScrollview.Panel.AddView(.....)
But to do that i have to declare him before somewere like
B4X:
Dim SuperScrollview as Scrollview
and adding elements to the scrollview works perfectly but i can't scroll to the bottom programmatically

Somewere in this forum i read that i shouldn't declare the Scrollview (or other elements) that are already created in the designer. Maybe this is why it is not scrolling to the bottom.
So my questions are:
- Why adding elements programmatically to the scrollview works perfectly even if i redeclared the scrollview?
- If i can add elements programatically why i can't scroll to the bottom?
- How to solve the problem?
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
by you do not need to declare views created by the designers it means that in order to use them you need to generate members but you must not initialize them. Generate members is the same as declaring them in globals.

for your questions,

1.- because memory allocation works this way, by redeclaring something you just point to the same "pool" of bytes, is the same when you say something like this:

dim b as button
b = sender

2.- if you can add elements programatically you can scroll to the bottom, delete any other redeclaration and keep the one in Globals.

3.- SuperScrollview.FullScroll(true) <- this should work without further issues, may be if it does not, you could try this library: https://www.b4x.com/android/forum/threads/lib-scrollview2d.19268/
 
Upvote 0

FrankBerra

Active Member
Licensed User
Longtime User
Thank you Enrique for answering

I checked again and I can confirm that my program is done as you suggested in your guidelines (Points 2 & 3) but it won't scroll to the bottom. It is weird :-/
I will try the library

Thank You
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…