Android Question Delay in Dialog Button Response in B4A(Solved)

kira

Member
Licensed User
Hey B4A folks,

I hope this message finds you well. I am currently working on a project using B4A (Basic4Android) and have encountered an issue with the B4XDialog component. Specifically, when I display a custom dialog using Dialog.ShowCustom, there is a delay of approximately 2-3 seconds before the "OK" and "Cancel" buttons become responsive. During this delay, clicking the buttons does not produce any action.

I have searched extensively on the website and other forums but couldn't find any similar issues or solutions. Therefore, I have no choice but to start a new thread to seek help.

B4A:
Sub Globals
    Private DateTimePicker1 As DateTimePicker
    Private xui As XUI 'ignore
    Private DateTimePickerPanel As B4XView
    Private Dialog As B4XDialog
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dialog.Initialize (Activity)
    If DateTimePickerPanel.IsInitialized = False Then
        DateTimePickerPanel = xui.CreatePanel("")
        DateTimePickerPanel.SetLayoutAnimated(0, 0, 0, 300dip, 150dip)
        DateTimePickerPanel.LoadLayout("1")
 
        DateTimePicker1.SetMinDate(DateTime.Now-DateTime.TicksPerDay*15)
        DateTimePicker1.SetMaxDate(DateTime.Now+DateTime.TicksPerDay*2)
        DateTimePicker1.SetSelectedValue(DateTime.Now)
 
        DateTimePicker1.backgroundColor = xui.Color_White
        DateTimePicker1.focusedTextColor = xui.Color_Gray
        DateTimePicker1.lineColor = xui.Color_Blue
        DateTimePicker1.fadeAwayEffect = True 'New
 
        DateTimePicker1.Show
    End If
 
'    Wait For (Dialog.Show("1234", "OK", "", "Cancel")) Complete (Result As Int)
    Wait For (Dialog.ShowCustom(DateTimePickerPanel, "OK", "", "Cancel")) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        ToastMessageShow($"$Time{DateTimePicker1.Selected}"$,True)

    End If
 
End Sub

I have attached the complete project file and the relevant layout file for reference. The issue seems to be related to the initialization or rendering of the custom dialog, but I have not been able to pinpoint the exact cause.Any insights, suggestions, or solutions would be greatly appreciated. Thank you in advance for your help!

Best regards
 

Attachments

  • 1.zip
    14.5 KB · Views: 87
Last edited:

kira

Member
Licensed User
Have you tried running the app in Release mode?
My test had no delay for clicking the buttons.
Hey PaulMeuris,

Thank you so much for your suggestion! I tried running the app in Release mode as you recommended, and it worked perfectly—the buttons are now responsive immediately. I really appreciate your help!

Best regards,
 
Upvote 0
Top