Android Question input template cannot be cast with swiftbutton error

harinder

Active Member
Licensed User
Longtime User
I am trying to use btn.tag tagged to swiftbuttons on positive response from an input template but getting following error
IMG_20200116_221532.jpg

My code is as follows. What am I doing wrong?:
B4X:
Sub btnselect_Click
    InputTemplate.lblTitle.Text = "Enter time (HH:MM)"
    InputTemplate.RegexPattern = "^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$"
    Wait For (Dialog.ShowTemplate(InputTemplate, "OK", "", "CANCEL")) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        Dim btn As SwiftButton
        btn=Sender
        Select btn.Tag
            Case "atd"
               btn.xlbl.Text = InputTemplate.Text
               lblatd.SetVisibleAnimated(1000,True)
            Case "medaypic"
               btn.xlbl.Text = InputTemplate.Text
               lblmedaypic.SetVisibleAnimated(1000,True)
        End Select
    End If
End Sub
 

Mahares

Expert
Licensed User
Longtime User
on positive response from an input template but getting following error
How about this code:
B4X:
Private swift1 As SwiftButton  'in globals       has btnselect as event name
Private swift2 As SwiftButton  'in globals         has btnselect as event name

Sub btnselect_Click
    Dim st1 As String ="atd"
    swift1.Tag=st1
    Dim st2 As String ="medaypic"
    swift2.Tag= st2
    Dim btn As SwiftButton = Sender
    btn.xlbl.Text=""
    InputTemplate.lblTitle.Text = "Enter time (HH:MM)"
    InputTemplate.RegexPattern = "^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$"
    Wait For (Dialog.ShowTemplate(InputTemplate, "OK", "", "CANCEL")) Complete (Result As Int)
    If Result = XUI.DialogResponse_Positive Then
        Select btn.Tag
            Case st1
                btn.xlbl.Text = InputTemplate.Text
                lblatd.SetVisibleAnimated(1000,True)
            Case st2
                btn.xlbl.Text = InputTemplate.Text
                lblmedaypic.SetVisibleAnimated(1000,True)
        End Select
    End If
End Sub
 
Upvote 0
Top