Android Question B4XPreferenceDialog help needed

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
hi pals,

please look at the following code - it was a result of massive help i got here and as final result i generated to suite my needs
it displays 2 types of messages - a confirm and a regular message with as much as i could flexibility
it works fine for me
two questions:

1: the message window allows scrolling
is there a way to prevent it?
or at least to make sure the title isn't scrolled

2:
as i want to be flexibe - is there a way to keep the title background same color as the background of the message boddy as it made by the theme?
this is not critical...

thanks

edit:
out of this scope - is there a way in B4A to create a function with optional parameters like in visual studio ?



B4X:
Public Sub zShowDialog (Title As String, TitlebackColor As Int, TitleTextColor As Int, _
                        Msg As String, msgAlign As String,  btnYES As String, btnNO As String, FontSize As Int, fontColor As Int, _
                        Theme As String, DialogHeight 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="Got It!"
    If msgAlign="" Then msgAlign="Right"
    If (msgAlign.ToUpperCase<>"RIGHT") And (msgAlign.ToUpperCase<>"LEFT") And (msgAlign.ToUpperCase<>"CENTER") Then msgAlign="Right"


    msgAlign=msgAlign.ToUpperCase
   
    prefdialog.Initialize(Activity, "", 300dip, DialogHeight)

    If Title <> "" Then
        prefdialog.AddSeparator(Title)
    End If
   
    prefdialog.AddMultilineTextItem("First", "", DialogHeight)
   
   
    If Theme.ToUpperCase="LIGHT" Then
        prefdialog.Theme = prefdialog.THEME_LIGHT
    Else
        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)
   
    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
           
            ft.TextField.SetTextAlignment("CENTER",msgAlign.ToUpperCase)
           
            Dim xfont As B4XFont=xui.CreateFont(Typeface.DEFAULT_BOLD,FontSize)
            ft.textfield.Font = xfont
           
            ft.TextField.TextColor = fontColor
           
            ft.TextField.Enabled = False
        End If
    Next
   
    Wait For (sf) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        bRet = True
    Else
        bRet = False
    End If
   
    Return bRet
   
End Sub
 

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
I thought I have answered in post #2.
i'm not talking about the title - i meant the background on the message body
currently i use there as light or dark
is it possible to set it for example to green or red?

can i control the buttons width ? font size? text color?
i control the font size of the message body but what about the buttons?

thanks
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
i'm not talking about the title - i meant the background on the message body
currently i use there as light or dark
is it possible to set it for example to green or red?

can i control the buttons width ? font size? text color?
i control the font size of the message body but what about the buttons?

thanks
Yes.
I have customized my PrefDialog with white background so I recommend you check my Web API Client code.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
can't open your template file
could you please send it is either text mode or a project or any other i can open?
It is a b4xtemplate file.
Meaning it is a zip file with different file extension only.

You can also copy the file and put in the additional library folder like any other b4xlib. Then create a new project from the IDE New menu.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Great that you have it solved, but for the sake of the community, please edit your title from 'PerfDialog' to 'B4XPreferenceDialog'. We all know you mean PreferenceDialog, but the search box will have a hard time with 'Perf' I hope we are not perforating anything. No reason to add the word 'question' because it is obvious.
 
Upvote 0
Top