Android Question Scroll down on panel?

Hi,

I just finished my first app and was building on that.

I use labels and B4XPlusMinus to input a values related to the labels. The objects are on a panel.

The number of objects exceed the screen space (in vertical direction). How can i make the panel such that when not all labels fit on the screen that the user can scroll down?

Thanks!
 

DonManfred

Expert
Licensed User
Longtime User
 
Upvote 0
Hi DonManfred,

Thank you for your answer. The new xCustomListView is a bit complicated for a starter like me (or maybe its not, but looks like it for a beginner). But viewing your post/link reminded me of an example i have seen from Erel. I opened all examples from the documentation and found a simple solution.

I use a scrollview and on the scrollview i load a panel with the input. See the AutoscaleExample2 from the documentation.

B4X:
' load the ScrollView.Panel layout file
    ScrollView1.Panel.LoadLayout("Page2Input")
    
    ' set the ScrollView.Panel.Height to the pnlSetup Panel height
    ScrollView1.Panel.Height = Panel5.Height
 
Upvote 0
That's strange, if i swap the code lines then the app crashes at startup.

I got the code from the autoscale example 2 from the B4A documention. There the height is also set after the palel is loaded on the scrollview.

Am i missing something?
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
Your code should work.
But, what is Panel5 ?
There is another example HERE.
I suppose that you have all the views on a Panel higher than the screen.
If yes, you should set the ScrollView1.Panel.Height to the height of this Panel.

Otherwise, post your project as a zip file, and I will have a look at it.
1589986325244.png

And attach it to the post with this button:
1589986352621.png
.
 
Upvote 0
Hello Klaus,

Thank you for your support/offer. Erel also! I attached the project.

I am a very beginner so please don't laugh ?

I want to make an app were a user (at first me) can log some variabels every day. Later my goal is that others also can use the app and define the variables.

Now it is very static (the variables and number of variables are defined in the code). Also i have to refer in the code to every B4XPlusMinus. I want to be able to this with a simple loop. For now i do not know how but hope to find out when i progress.

Any additional advice is welcome!
 

Attachments

  • Export.zip
    22.4 KB · Views: 234
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
I have downloaded your exported project and I understand your question, but I do not have time to give you a proper reply at the moment. I will send you something later if nobody else helps you out first.

Meanwhile I recommend a book that I found extremely useful when I started with B4A - in fact I still refer to it often. It is "B4A - Rapid Android App Development using BASIC" - ISBN number 9781512296259. As well as being a thorough B4A reference it contains a lot of useful guidance.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You can define an Array for the B4XPlusMinus objects.

Example:
B4X:
Private btnPlusMinus(13) As B4XPlusMinus
Private B4XPlusMinus1 As B4XPlusMinus
Private B4XPlusMinus2 As B4XPlusMinus
Private B4XPlusMinus3 As B4XPlusMinus
Private B4XPlusMinus4 As B4XPlusMinus
Private B4XPlusMinus5 As B4XPlusMinus
...
And in ActivityCreate:
B4X:
btnPlusMinus = Array As B4XPlusMinus (B4XPlusMinus1, B4XPlusMinus2, B4XPlusMinus3, ...

Then you could go through the buttons in a For / Next loop like:
B4X:
For i = 0 To btnPlusMinus.Length - 1
            
Next

Be aware that you have B4XPlusMinus2 and B4XPlusMinus2B, you need to know which index corresponds to which Button.
btnPlusMinus(0) is B4XPlusMinus1
btnPlusMinus(1) is B4XPlusMinus2

For your layouts, you should study anchors.
This will save quite some Designer Scripts code.
 
Upvote 0
Thank you Klaus!

I did study the anchors but i think i am not 100% used to all the benefits. I will have a look if i can simplify some more.

On ActivityCreate, do i still have to list all objects (B4XPlusMinus1, B4XPlusMinus2, etc)?
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
On ActivityCreate, do i still have to list all objects (B4XPlusMinus1, B4XPlusMinus2, etc)?

Yes you do, and that means that Klaus's suggestion is only a partial answer to your problem. At the moment I do not have a satisfactory answer either. I put a related question on the Forum this morning but so far over twenty people have looked at it and none have responded with a solution.

I am telling you this not to discourage you but rather the opposite. You are trying to do a difficult thing so do not be put off if you do not immediately succeed. By the way, your difficulties have nothing to do with B4A; your problems are rooted in the nature of the data that you are trying to collect.
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
Here is a sample project that I hope will answer your immediate questions. I have to thank @klaus for giving me an answer in another thread that helped me get past a problem. So we are both learning here.
 

Attachments

  • Data Collection.zip
    11 KB · Views: 291
Upvote 0
Here is a sample project that I hope will answer your immediate questions. I have to thank @klaus for giving me an answer in another thread that helped me get past a problem. So we are both learning here.

Hi Brian,
Thank you very much for your example! I only saw it today. I stopped with B4A last year because i had some other things to do. I see now that your example was what i was looking for.

Thank you! I will pick up where i left! Sorry for my late reply!
 
Upvote 0
Well Brian,

Many thanks again! I see you really did some effort to help me with my questions. I am ashamed that i only saw it today.

Your example is much appreciated!
 
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime User
Don't waste time on ScrollView, the sooner you start using xCustolistView the better for you.;);)
 
Upvote 0
Top