Android Question prefdialog - need an expert eye to look & help

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User

i've created this following general purpose function to be used in my B4A project
it works very nice but i have a few (non critical issues)

the title - how can i lock the title so it will not be scrolled when the user scrolls the message content?
i want the title to be fixed as the bottom bar with the buttons

how can i change the width of the buttons so i can use extra text if needed?

is there a way to change the background color other than the theme?
for example red background and yellow text

4. can i change the background color of the bottom bar - the buttons bar?

i will appreciate any input
and of course i will be dancing on the table (you should mot even imagine this horror sight) if anyone will be kind and modify the code to support what i dream about...


Public Sub zgShowDialog (Title As String, TitlebackColor As Int, TitleTextColor As Int, _
                        Msg As String, msgAlign As String, FontSize As Int, fontColor As Int, _ 
                        btnYES As String, btnYES_TextColor As Int, btnNO As String, btnNO_TextColor As Int, _
                        Theme As String, DialogHeight As Int, CanScroll As Boolean, Top As Int) As ResumableSub

    Dim bRet As Boolean = False
    Private Xui As XUI
    Dim prefdialog As PreferencesDialog

    If DialogHeight<150dip Then DialogHeight=150dip
    If FontSize<12 Then FontSize=12
    If btnYES="" And btnNO="" Then btnNO="OK"
    If msgAlign="" Then msgAlign="Right"
    If (msgAlign.ToUpperCase<>"RIGHT") And (msgAlign.ToUpperCase<>"LEFT") And (msgAlign.ToUpperCase<>"CENTER") Then msgAlign="Right"
    If TitlebackColor=0 Then TitlebackColor = Colors.Red
    If TitleTextColor=0 Then TitleTextColor = Colors.Yellow
    If Top = 0 Then Top = 100dip

    prefdialog.Initialize(Activity, "", 300dip, DialogHeight)

    If Title <> "" Then
    End If
    prefdialog.AddMultilineTextItem("First", "", DialogHeight)
    If Theme.ToUpperCase="LIGHT" Then
        prefdialog.Theme = prefdialog.THEME_LIGHT
        prefdialog.Theme = prefdialog.THEME_DARK
    End If
    If Title<>"" Then
        If TitlebackColor<>0 Then prefdialog.SeparatorBackgroundColor = TitlebackColor
        If TitleTextColor<>0 Then prefdialog.SeparatorTextColor = TitleTextColor
    End If

    Dim Data As Map = CreateMap("First": Msg)
    Dim sf As Object = prefdialog.ShowDialog(Data, btnYES, btnNO)

    If Top > 0 Then
        prefdialog.Dialog.Base.Top = Top
    End If

    For i = 0 To prefdialog.PrefItems.Size - 1
        Dim pi As B4XPrefItem = prefdialog.PrefItems.Get(i)
        If pi.ItemType = prefdialog.TYPE_MULTILINETEXT Then
            Dim ft As B4XFloatTextField = prefdialog.CustomListView1.GetPanel(i).GetView(0).Tag
            Dim xfont As B4XFont=Xui.CreateFont(Typeface.DEFAULT_BOLD,FontSize)
            ft.textfield.Font = xfont
            ft.TextField.TextColor = fontColor
            ft.TextField.Enabled = False
        End If

    If CanScroll = False Then
        Sleep(0) = + 10dip
    End If

    If (btnNO<>"") And (btnNO_TextColor<>0) Then
        Dim btnPrefCancel As B4XView = prefdialog.Dialog.GetButton(Xui.DialogResponse_Cancel)
        btnPrefCancel.Width = btnPrefCancel.Width + 20dip
        btnPrefCancel.Left = btnPrefCancel.Left - 20dip
        btnPrefCancel.TextColor = btnNO_TextColor
    End If
    If (btnYES<>"") And (btnYES_TextColor<>0) Then
        Dim btnPrefOk As B4XView = prefdialog.Dialog.GetButton(Xui.DialogResponse_Positive)
        btnPrefOk.Width = btnPrefOk.Width + 20dip
        btnPrefOk.Left = 20dip        'btnOk.Left - 10dip
        btnPrefOk.TextColor = btnYES_TextColor
    End If
    Wait For (sf) Complete (Result As Int)
    If Result = Xui.DialogResponse_Positive Then
        bRet = True
        bRet = False
    End If
    Return bRet
End Sub