Android Question Spiner feature

red30

Well-Known Member
Licensed User
Longtime User
On some devices, if I scroll the screen and hit the spiner with my finger, the spiner list opens and scrolls. Why it happens? Is it possible to make the list of spiners open only by pressing?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Example of disabling the spinner while the user scrolls the list:
B4X:
Sub clv1_ScrollChanged (Offset As Int)
   ScrollChangedIndex = ScrollChangedIndex + 1
   Dim MyIndex As Int = ScrollChangedIndex 'ScrollChangedIndex is a global int variable.
   spinner.Enabled = False
   Sleep(300)
   If MyIndex = ScrollChangedIndex Then spinner.Enabled = True
End Sub
 
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
B4X:
Sub Globals
    Private ScrollChangedIndex As Int
End Sub
Sub CLV_Second_ScrollChanged (Offset As Int)  
    Dim pnl As Panel = CLV_Second.GetPanel(2)
    Dim spn As Spinner = pnl.GetView(1)

    ScrollChangedIndex = ScrollChangedIndex + 1
    Dim MyIndex As Int = ScrollChangedIndex 'ScrollChangedIndex is a global int variable.
    spn.Enabled = False
    Sleep(300)
    If MyIndex = ScrollChangedIndex Then spn.Enabled = True
End Sub

When I try to roll CLV and touch the spinner accidentally, the spinner is opening and rolling, but CLV is not. What's wrong?
CustomListView v1.64
 
Last edited:
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
I do not understand. Can I remove the spinner scrolling when I scroll through the list?
 
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
And can you somehow check the click only in this area of the screen? If the finger is still holding, then do not open the list of spiner.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I agree with Erel, from my personal experience, it always turned bad when inserting scrollable views inside other scrollable views.

In a similar occasion, I dealt with it by removing spinners and adding labels with a button at the right corner to do the dropdown. For the dropdown I used an input list.

Example using a scrollview (ugly one but it shows how I did it):

B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Type typeSpinner(lb As Label,spinnerDesc As String,lstOfItems As List,selectedIndex As Int)
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.
   Private sv As ScrollView,pnlSv As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   'Activity.LoadLayout("Layout1")
   sv.Initialize(1000dip)
   pnlSv=sv.Panel
   Activity.AddView(sv,0,0,100%x,100%y)
   For i=0 To 99
       
       Private lb As Label
       lb.Initialize("")
       lb.Text="spinner "&i
       
       Private lstOfItems As List
       lstOfItems.Initialize
       For j=0 To 99
           lstOfItems.Add("spinner "& i & " -> item "&j)
       Next
       
       Private btnSpinner As Button
       btnSpinner.Initialize("btnSpinner")
       Private tempSpinnerType As typeSpinner
       tempSpinnerType.Initialize
       tempSpinnerType.lb=lb
       tempSpinnerType.spinnerDesc="my spinner "&i
       tempSpinnerType.lstOfItems=lstOfItems
       tempSpinnerType.selectedIndex=-1
       btnSpinner.Tag=tempSpinnerType
       btnSpinner.Text="v"
       
       pnlSv.AddView(lb,0,i*40dip,200dip,39dip)
       pnlSv.AddView(btnSpinner,201dip,i*40dip,39dip,39dip)
   Next
   
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub btnSpinner_click
   Private btnSpinner As Button=Sender
   Private tempSpinnerType As typeSpinner=btnSpinner.Tag
   Private lb As Label=tempSpinnerType.lb
   Private spinnerDesc As String=tempSpinnerType.spinnerDesc
   Private lstOfItems As List=tempSpinnerType.lstOfItems
   Private selectedIndex As Int=tempSpinnerType.selectedIndex
   InputListAsync(lstOfItems, "Select Value of "&spinnerDesc,selectedIndex, True)
   Wait For InputList_Result (Index As Int)
   If Index <> DialogResponse.CANCEL Then
       Private selectedVal As String=lstOfItems.Get(Index)
       lb.Text=selectedVal
       tempSpinnerType.selectedIndex=Index
   End If
       
End Sub
 
Upvote 0
Top