Android Question CLSWheel - Identify Entry Number Of Selection Made

Big Dave

Member
Licensed User
Longtime User
Hi

I am using the CLSWheel class and need to identify the "index" entry of the line selected. Is this possible?

Thanks
 

klaus

Expert
Licensed User
Longtime User
I suppose that you are speaking about this ClsWheel.

I am using the CLSWheel class and need to identify the "index" entry of the line selected. Is this possible?
No.
What exactly do you want.
As there are several wheels with different number of items there is no index of the 'seleted' line.
There is one index per wheel, these are not available.
But you have the EndScroll event and you have the Selection property which returns the content of the entire line in the middle of the wheel.
You could use something like this:
B4X:
Sub MyWheel_EndScroll
    Log(MyWheel.Selection)
End Sub
 
Upvote 0

Big Dave

Member
Licensed User
Longtime User
Hi Klaus

I load a wheel with text entries from an indexed table. If another selection is made I want to use the index from the selection to read another indexed table. There is a "tag" field I believe but not sure if that is one per wheel or one per selection. If its selection could I not put the index value there. Alternatively is there something else I could use that looks as good? Thanks.
 
Upvote 0

Big Dave

Member
Licensed User
Longtime User
Not sure how to set up the EndScroll event as I use a Closed event. The "A" log returns 0 being the first entry in the table but the "B" log returns -1. No idea what I am doing wrong.
B4X:
Sub lblSystemName_Closed (Cancelled As Boolean, Selection As String)
    Log("Enter lblSystemName_Closed")
    Log ("intSystemPos A " & intSystemPos)
    If Cancelled = False Then
        lblSystemName.Text = Selection
        intSystemPos = lstSystemID(0).IndexOf(whlSystem.Selection)
        Log ("intSystemPos B " & intSystemPos)
    End If
    
End Sub
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
It works also with the Closed event.
Unfortunately, you don't give enough information.
What is the content of lstSystemID(0)?
Is it the list you transmit when you initialize the wheel?
You have lblSystemName as the event name and whlSystem as the wheel name is it the same object?


I tested it in the ClsWheel demo program like this:
B4X:
Sub whlCustomSingle_Closed(Canceled As Boolean, Selection As String)
    Private day As String
    Private Index As Int
    
    day = whlCustomSingle.Selection
    Index = lstCustomSingle(0).IndexOf(day)
    Log(day & " / " & Index)
End Sub
 
Upvote 0

Big Dave

Member
Licensed User
Longtime User
lstSystemID(0) is the table used to populate the wheel. It contains a list of names and the id of the selected name is used to reference another database table. Will this still work if the selected name is not unique as I want to do the same thing for another table which will have duplicate names.

B4X:
Sub lblSystemName_Closed (Cancelled As Boolean, Selection As String)
    Log("Enter lblSystemName_Closed")
    
    Log ("intSystemPos A " & intSystemPos)
    If Cancelled = False Then
        lblSystemName.Text = Selection
        intSystemPos = lstSystemName(0).IndexOf(Selection)
'        intSystemPos = lstSystemName(0).IndexOf(lblSystemName.Text)
        Log ("intSystemPos B " & intSystemPos)
    End If
    
End Sub

The above code works and line 7 and 8 return the same result so not sure if there is any difference, hence my question about duplicate entries.

Klaus, my grateful thanks to you for your help.
 
Upvote 0
Top