Android Question Floating window - help needed

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
Hi

Can anyone assist on how to create such a confirm window?
A sample code will be highly appreciated
 

Attachments

  • Screenshot_20250313_203712_Solitaire Master.jpg
    Screenshot_20250313_203712_Solitaire Master.jpg
    366.5 KB · Views: 55

Brian Dean

Well-Known Member
Licensed User
Longtime User
Overlay your page with a semi-transparent panel. On the panel load a layout with the smaller panel containing the text and buttons. That is how most dialogues work, I think.

If you need a demo let me know, but I am tied up for the next hour or two.
 
Last edited:
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
Here is a very quick example - not fully tested and could be improved, probably.

Screenshot.jpg


Here is the code :

B4X:
Sub btnDialogue_Click
    screen.Initialize("overlay")
    screen.Color = xui.Color_ARGB(0x80, 0x20, 0x20, 0x20)
    screen.Elevation = 16dip                               ' Ensure any elevated views are covered
    Activity.AddView(screen, 0, 0, 100%x, 100%y)        ' Load background panel
    base.Initialize("")
    screen.AddView(base, 5%x, 30%y, 90%x , 120dip)
    base.LoadLayout("Dialogue")
    lblQuery.Text = "Are you sure that you want to leave the game?"
    lblNo.Text = "Exit"
    lblYes.Text = "Cancel"
End Sub

Sub overlay_Touch (Action As Int, X As Float, Y As Float)
    Return True                                                                            ' Ensure touches on the overlay are consumed 
End Sub

Sub lblNo_Click
    MsgboxAsync("Exit the game", "Response received") 
    clear
End Sub

Sub lblYes_Click
    MsgboxAsync("Continue with the game", "Response received")
    clear
End Sub

' Clear overlay dialogue
Sub clear
    base.RemoveAllViews
    screen.RemoveView 
End Sub

Here is the project :
 

Attachments

  • Overlay.zip
    10.8 KB · Views: 23
Last edited:
Upvote 0
Top