Spinner View alternatives

BPak

Active Member
Licensed User
Longtime User
Spinner is great as it takes up liitle area on the screen but when used it pops up a big selection area is taken on the screen.

On my Tablet I choose to use a Panel as the main area of the screen rather than use the whole activity area. That way my App has similar display Layout as used on small mobile units.

Thus using Spinner causes the pop up selection to go the full width of the Activity not the Panel where it is located.

This looks ugly.

Is there any other Library or View that is similar to the Spinner that would be more constrained to the Panel area?
 

mc73

Well-Known Member
Licensed User
Longtime User
One way is to add a label in you panel. In the label_click event, show a listView in your panel containing the contents you wish to show. When a listView item is clicked, set its visible property to false and change your label's text to the listview's item.
As an example:
B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
Dim lv As ListView 
Dim lb As Label 
End Sub

Sub Activity_Create(FirstTime As Boolean)
lb.Initialize ("label")
lb.Text="tap here"
lb.Gravity =Gravity.CENTER 
Activity.AddView (lb,0,0,Activity.Width/2,36dip)
lv.Initialize ("list")
Activity.Addview (lv,0,lb.Height,lb.Width,Activity.Height/2)
lv.Visible =False
For k=0 To 9
lv.AddSingleLine ("item " & k)
Next
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub label_click
lv.Visible =True:lv.RequestFocus 
End Sub

Sub list_ItemClick (Position As Int, Value As Object)
lb.Text=lv.GetItem (Position)
lv.Visible =False
End Sub
 
Last edited:
Upvote 0

BPak

Active Member
Licensed User
Longtime User
Thank you both for the solutions.

The ListView looks the simplest way for me.
 
Upvote 0

Ricky D

Well-Known Member
Licensed User
Longtime User
I use mc73's ways to display simple "spinner" lists.

I create a 2px border around the list

regards, Ricky
 
Upvote 0

BPak

Active Member
Licensed User
Longtime User
Thanks Ricky D.

I ended up using a colored panel with the ListView in it and having a small border by making the ListView smaller than the Panel.

It looks really neat and pro.

Thanks everyone.

PS - Looked nice but did not work on the Tablet as expected.
The panel with the ListView came up over a ScrollView and left the selected ListView Item behind on the screen (sometimes).

Must be doing something wrong in my code.

New idea - use two buttons to go to "Previous" "Next" in the List.
 
Last edited:
Upvote 0
Top