Android Question button longclick time set?

Hacky35

New Member
Hello,
first of all, thank you everyone. I'm still a beginner, so my questions might seem simple :)

How can I change the button's longclick time?
 

mangojack

Expert
Licensed User
Longtime User
Possible solution ...

 
Upvote 0

Hacky35

New Member
Possible solution ...
Thank you for your help,
I couldn't install the example, it gives an old Android version message.
Also, the application I'm trying to write has 48 buttons.
I think there will be too many "sub"s for each one.
I wish there was a command similar to
longclick, (delay_Time)

Regards
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Full example with SwiftButton (XUI Views), supporting multiple buttons. Make sure that the Event Name of all of them is set to SwiftButton:
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private SwiftButton1 As SwiftButton
    Private SwiftButtonsIndices As Map = CreateMap()
End Sub

Public Sub Initialize
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
End Sub

Private Sub SwiftButton_ButtonDown
    Dim btn As SwiftButton = Sender
    Dim Index As Int = SwiftButtonsIndices.GetDefault(btn, 0)
    Index = Index + 1
    SwiftButtonsIndices.Put(btn, Index)
    Sleep(3000)
    Dim NewIndex As Int = SwiftButtonsIndices.GetDefault(btn, 0)
    If NewIndex = Index Then
        Log("Long click after 3 seconds")
        XUIViewsUtils.PerformHapticFeedback(btn.mBase)
    End If
End Sub

Private Sub SwiftButton_ButtonUp
    Dim index As Int = SwiftButtonsIndices.GetDefault(Sender, 0)
    SwiftButtonsIndices.Put(Sender, index + 1)
End Sub
 

Attachments

  • 22.zip
    13.8 KB · Views: 13
Last edited:
Upvote 0
Top