Android Question Panel As Dialog

Discussion in 'Android Questions' started by Mike1970, May 27, 2019.

  1. Mike1970

    Mike1970 Active Member Licensed User

    Hi, i need to have a custom dialog.
    I tried the Dialog library loaded with a layout (with a panel), but the dialog has the black borders.

    417285978-min.jpg

    If there is a way to remove the background color from this dialog, i think it's good, but if it's not possilble to do this, i need something that esthetically looks like a panel in front of everything
     
    Last edited: May 27, 2019
  2. Star-Dust

    Star-Dust Expert Licensed User

    The image is not well is too small, post an image if possible larger.:D

    Anyway it is more useful to see the code you use to give you some suggestions
     
  3. Mike1970

    Mike1970 Active Member Licensed User

    Sorry, it's a screenshot :D i should have resize it somehow :confused:

    Code:
    Dim cd As CustomLayoutDialog

    ...

    Sub btnImpostaLuogoAUTO_Click
        ShowGP
    End Sub

    ...

    Sub ShowGP
        cd.ShowAsync(
    """"""""NullTrue)
        cd.SetSize(
    100%x100%y)
        
        
    Wait For Dialog_Ready (DialogPanel As Panel)
        DialogPanel.LoadLayout(
    "GooglePLaces")
        
        DialogPanel.Color = 
    Colors.ARGB(0,0,0,0)
    End Sub
    It's technically the same code used in the example of the library:
    https://www.b4x.com/android/forum/threads/customlayoutdialog-with-customlistview.82259/#content
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Check B4XDialog. It is made of a panel with all kinds of features. You can customize it in many ways.
     
  5. DonManfred

    DonManfred Expert Licensed User

    Please do NOT post big images! put it as attachment.
     
  6. Mike1970

    Mike1970 Active Member Licensed User

    done
     
  7. Mike1970

    Mike1970 Active Member Licensed User

    I think i already tested in the past that object, but if i'm not wrong the problem was that it doesn't shows in front of everything, anyway I will take another look now
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    It will show above all other views unless you added a panel with an elevation higher than 4dip (in that case you can easily change the dialog elevation).
     
    Mike1970 likes this.
  9. Mike1970

    Mike1970 Active Member Licensed User


    Ok Done! it's perfect i used the B4XDialog, the problem is that when i use the Backbutton it doesn't close the dialog but close the activity :(
     
  10. Star-Dust

    Star-Dust Expert Licensed User

    You have to intercept the BACK key in the activity
     
  11. Mike1970

    Mike1970 Active Member Licensed User

    i tried, it closes anyway

    Code:
    Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
        If ((KeyCode = 269Or (KeyCode = KeyCodes.KEYCODE_BACK)) And (pnlDialog.Tag == FalseThen
            HandleBackKey
        
    Else If (pnlDialog.Tag == TrueThen
            btnOkDialog_Click
            
    Return False
        
    Else
            
    Return True
        
    End If
    End Sub
    I saved in the pnlDialog.Tag if the dialog is shown or not (if false is it not shown, if true yes)
    then in btnCloseDialog_Click i have:

    Code:
    Sub btnOkDialog_Click
        dialog.Close(
    DialogResponse.POSITIVE)
        pnlDialog.Tag = 
    False
    End Sub
    Edit: Before you ask, the sub "HandleBackKey" works properly (it show a classic MsgBoxAsync, if i hit "No" or "Cancel" it doensn't go back), the problem is only with the B4XDialogs
     
    Last edited: May 27, 2019
  12. Star-Dust

    Star-Dust Expert Licensed User

    Code:
    Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
        If ((KeyCode = 269Or (KeyCode = KeyCodes.KEYCODE_BACK)) And (pnlDialog.Tag == FalseThen
            HandleBackKey
            
    Return True  '<-------------------------------
        Else If (pnlDialog.Tag == TrueThen
            btnOkDialog_Click
            
    Return False
        
    Else
            
    Return True
        
    End If
    End Sub
     
    jimmyF and Mike1970 like this.
  13. Mike1970

    Mike1970 Active Member Licensed User

    ohu, ok better, but now if the dialog is show and i press the backbutton it closes and then it runs the HandleBacKey sub immediatly

    Like it pass through the KeyPress event two time, the first closes the dialog (so the tag now is False) and then it pass to the first condition
     
  14. Star-Dust

    Star-Dust Expert Licensed User

    do something like that, now I can't write you the exact code because I have something else on my hands that I can't leave
    Code:
    If DialogIsOpen=False then HandleBackKey
     
    Mike1970 likes this.
  15. Mike1970

    Mike1970 Active Member Licensed User

    yes, this is the functionality of this if:

    Code:
    If ((KeyCode = 269Or (KeyCode = KeyCodes.KEYCODE_BACK)) And (pnlDialog.Tag == FalseThen
            HandleBackKey
    but it fails
     
  16. Star-Dust

    Star-Dust Expert Licensed User

    Try it
    Code:
    Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
        If ((KeyCode = 269Or (KeyCode = KeyCodes.KEYCODE_BACK)) Then
            
    If (pnlDialog.Tag == Falsethen  
                 
    ' Dialog is Close - Close Activity
                 Activity.close
            
    Else
                 
    ' Dialog is Open - Close Dialog
                 btnOkDialog_Click
            
    End If
            
    Return True
        
    Else
            
    Return False
        
    End If
    End Sub
    If the BACK button is intercepted several times, then put a sleep (300) before closing the dialog box.
     
  17. Mike1970

    Mike1970 Active Member Licensed User

    It's not allowed to put Sleep and Wait For in Activity_KeyPress
     
  18. Star-Dust

    Star-Dust Expert Licensed User

    there are other methods ... cmq now you have to do it alone
     
  19. Mike1970

    Mike1970 Active Member Licensed User

    It doens't work, behave like before :(
     
  20. Johan Hormaza

    Johan Hormaza Active Member Licensed User

    Try this
    Code:
    Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
        If KeyCode = KeyCodes.KEYCODE_BACK Then
            
    If dialog.Close(xui.DialogResponse_Cancel) Then Return True
        
    End If
        
    Return False
    End Sub
     
    Erel likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice