Android Question [Solved] [B4X] XUI Views assistance required: "Dialog.ShowCustom(..."

Discussion in 'Android Questions' started by fredo, Mar 28, 2019.

  1. fredo

    fredo Active Member Licensed User

    In a certain project, all "outdated" CustomLayoutDialogs are to be converted to "[B4X] XUI Views".

    After looking at some examples the creation of a custom dialog is basically no problem.

    Nevertheless, I still don't seem to do everything right, because the following display errors occur in the enclosed example project:

    1.) At the first call of the dialog the "B4XFloatTextField" is not displayed, at the second call it is.

    2.) The height of the "B4XFloatTextField" is not displayed as intended.​


    #Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    'SupportedOrientations possible values: unspecified, landscape or portrait.
        #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #End Region

    #Region  Activity Attributes
    #FullScreen: true
    #IncludeTitle: false   
    #End Region

    Sub Process_Globals
    End Sub

    Sub Globals
    Private Base As B4XView
    Private xuiDialog As B4XDialog
    Private xuiDialogPanel2 As B4XView
    Private B4XFloatTextField1 As B4XFloatTextField
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
    End Sub
    Sub Activity_Resume
    End Sub
    Sub Activity_Pause (UserClosed As Boolean)
    End Sub

    Sub XuiInits As ResumableSub
    ' [B4X] XUI Views - Cross platform views and dialogs
        '         Erel -->
        '         Erel -->
        Base = Activity

        xuiDialog.Initialize (Base)
        xuiDialog.BackgroundColor = 
        xuiDialog.BlurBackground = 
        xuiDialog.BorderColor = 
        xuiDialog.ButtonsColor = 
        xuiDialog.TitleBarColor = Starter.intColorPrimaryLight
        xuiDialog.ButtonsTextColor = Starter.intColorAccent
        xuiDialog.ButtonsOrder = 
    Array As Int(Starter.XUI.DialogResponse_Negative, Starter.XUI.DialogResponse_Cancel, Starter.XUI.DialogResponse_Positive)
        xuiDialogPanel2 = Starter.XUI.CreatePanel(
    Return Null
    End Sub

    Sub Button1_Click As ResumableSub
    ' Custom dialog
    If Not(xuiDialog.IsInitialized) Then
    wait for(XuiInits) complete(x As Object)
    End If
    Dim InputFieldHeight As Int = 48dip *3
    00098%x, InputFieldHeight) 
        xuiDialog.Title = 
    "yyy title"
        xuiDialog.PutAtTop = 
    Dim rs As ResumableSub = xuiDialog.ShowCustom(xuiDialogPanel2, "OK""""Cancel")
    Dim ok As B4XView = xuiDialog.GetButton(Starter.XUI.DialogResponse_Positive)
    Dim cancel As B4XView = xuiDialog.GetButton(Starter.XUI.DialogResponse_Cancel)
    0, ok.Parent.Width / 2 + 2dip, ok.Top, ok.Parent.Width / 2 - 4dip, ok.Height)
    02dip, cancel.Top, cancel.Parent.Width / 2 - 4dip, cancel.Height)

        B4XFloatTextField1.mBase.Height = InputFieldHeight

        B4XFloatTextField1.mBase.Color = 
    Colors.DarkGray ' .White
        B4XFloatTextField1.HintColor = Colors.Yellow
        B4XFloatTextField1.Focused = 
        B4XFloatTextField1.HintText = 
    "yyy hinttext"
        B4XFloatTextField1.Text = 
    "This is a preset text"
    Wait For (rs) Complete (Result As Int)
    If Result = Starter.XUI.DialogResponse_Positive Then
    Log("#-  x2188,  B4XFloatTextField1.Text=" &  B4XFloatTextField1.Text)
    End If
    Return Null

    End Sub
    What am I doing wrong?


    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    Why aren't you using B4XInputTemplate? It will be easier than creating a custom dialog.

    1. No reason for XuiInits to be a resumable sub.
    2. Don't ignore this very important warning:
    Panel size is unknown. Layout may not be loaded correctly.

    Load the layout after you call xuiDialogPanel2.SetLayoutAnimated.
  3. fredo

    fredo Active Member Licensed User

    The layout used here should be as simple as possible for getting started with ShowCustom() before using more complex layouts.​

    This is a leftover from several awkward sleep() attempts.​

    That's for sure. Age-related temporary technician arrogance to harmless looking hints often leads unnecessarily to time-consuming loss of productivity.​

    That was it. Thank you.​
  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