Android Question How to add spinner in Designer

DickD

Active Member
Licensed User
I'm trying to position a spinner in the Designer in B4A 6.5. I've created a spinner called VenueSpinner in the designer and located it at a certain position on the screen. I've created the equivalent in code as shown below. When I run the app I get a small down arrow at the Designer location but it does nothing. The actual spinner shows up in the coordinates shown in the activity.addview location.

Bottom line: Is it possible to use the spinner in the Designer to control the initial location and then let the .addview display it elsewhere when selected?

B4X:
Sub Vspinner
 VenueSpinner.Initialize("Spinner")
 VenueSpinner.TextSize = 14
 VenueSpinner.AddAll(VenueList)
 Activity.AddView(VenueSpinner,10dip,20dip,200dip,30dip)
 VenueSpinner.Enabled = True
 VenueSpinner.Visible = True
 VenueSpinner.BringToFront
 VenueSpinner.RequestFocus
 VenueSpinner.Color = 0xFFFFFF
End Sub
 

Indy

Active Member
Licensed User
Longtime User
Hi

I think you need to add the view first before populating it. Swap lines 3 and 4 around.
 
Upvote 0

ronell

Well-Known Member
Licensed User
Longtime User
Bottom line: Is it possible to use the spinner in the Designer to control the initial location and then let the .addview display it elsewhere when selected?
yes,
then you can change the view location at runtime, no need to use .addview

B4X:
spinner.left = 50%x - spinner.width/2
spinner.top = 50%y - spinner.height/2
'display at center of screen
 
Upvote 0

Indy

Active Member
Licensed User
Longtime User
That didn't make a difference.

Apologies, I didn't read your post proppery and therefore misinformed you. Ronnel's solution is correct, although I believe you can also use the "SetLayout" method. Something like;

B4X:
VenueSpinner.SetLayout

Has to be done after you have added the view. Hope this helps.
 
Upvote 0

DickD

Active Member
Licensed User
yes,
then you can change the view location at runtime, no need to use .addview

B4X:
spinner.left = 50%x - spinner.width/2
spinner.top = 50%y - spinner.height/2
'display at center of screen
Without .addview the spinner doesn't appear on the screen at all - anywhere. I guess I'm sticking to an InputList which is SOOOOO much easier to use even if it doesn't give me the control I needed from a spinner.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I guess I'm sticking to an InputList which is SOOOOO much easier to use even if it doesn't give me the control I needed from a spinner.
This is not the correct solution. The correct solution is to learn how to use the designer.

1. Specifically you should never call Initialize or AddViews on views added with the designer.
2. It is very simple to change the position of views added with the designer.

I recommend you to go over the visual designer tutorial:
 
Upvote 0
Top