Android Question help needed: B4XPreferenceDialog - title & text

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
hi,

got great help from José J. Aguilar

now i need one simple thing - how do i add a title & message simple text to B4XPreferenceDialog
i don't need any data entry etc
i use it as simple msgdialog

thank you
 

Mahares

Expert
Licensed User
Longtime User
i use it as simple msgdialog
There are other simpler ways than using a B4XPreferenceDialog for this, but here is your request fulfilled with a full example:
B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private prefdialog As PreferencesDialog
End Sub

Public Sub Initialize
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")  'has button1
    prefdialog.Initialize(Root, "Preference Dialog Message", 300dip, 300dip)
    prefdialog.AddMultilineTextItem("First", "", 300dip)
End Sub

Private Sub Button1_Click
    Dim Data As Map = CreateMap("First": "This is an important B4X Preference Dialog message box")
    Dim sf As Object = prefdialog.ShowDialog(Data, "OK", "CANCEL")  
    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", "CENTER")
            Dim xfont As B4XFont=xui.CreateFont(Typeface.DEFAULT_BOLD,32)
            ft.textfield.Font = xfont
            ft.TextField.TextColor =xui.Color_Magenta
            ft.TextField.Enabled = False
        End If
    Next

    Wait For (sf) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        Dim f As String = Data.Get("First")
        Log(f)
    End If
Zeev, you do not need to start your thread title with: 'help needed'. It is obvious when you post you are going to need help. So there is no need to be redundant.
 
Last edited:
Upvote 0

aeric

Expert
Licensed User
Longtime User
Look like this?


B4X:
Private Sub CreateDialog3
    PrefDialog3.Initialize(Root, "Delete", 300dip, 70dip)
    PrefDialog3.Dialog.TitleBarColor = xui.Color_RGB(220, 20, 60)
    PrefDialog3.AddSeparator("default")
End Sub

Private Sub ShowDialog3 (Item As Map)
    PrefDialog3.Title = "Delete Item"
    Dim sf As Object = PrefDialog3.ShowDialog(Item, "OK", "CANCEL")
    #If B4A or B4i
    PrefDialog3.Dialog.Base.Top = 100dip ' Make it lower
    #Else
    Sleep(0)
    PrefDialog3.CustomListView1.sv.Height = PrefDialog3.CustomListView1.sv.ScrollViewInnerPanel.Height + 10dip
    #End If
    PrefDialog3.CustomListView1.GetPanel(0).GetView(0).Text = Item.Get("Item")
    PrefDialog3.CustomListView1.GetPanel(0).GetView(0).Color = xui.Color_Transparent
    PrefDialog3.CustomListView1.sv.ScrollViewInnerPanel.Color = xui.Color_Transparent
    Wait For (sf) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        xui.MsgboxAsync("Item deleted!", "Delete")
    End If
End Sub

or refer to CreateDialog3 and ShowDialog3 in my Web API Client project.
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
your sample looks exactly what i need
however i couldn't get it to work
any chance to get a working sample?
many thanks
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
thanks
what other ways you mean?
i need a msgdialog that will not disapear when the app is interrupted so when i get back to it the msgdialog will still be showing
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
a working sample?
You just need to add CreateDialog3 in B4XPage_Created and call it by passing a Map.

B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    CreateDialog3
End Sub

Private Sub Button1_Click
    ShowDialog3(CreateMap("Item": "This is a message"))
End Sub
 

Attachments

  • MessageDialog.zip
    14.2 KB · Views: 145
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
dear Pals

i managed to resolve the issues i had
now it is time to implement the solution within my app
that's going to be quite a long time work but i hope it will do the job i need it to do
many thanks to all of you who came to my assistance and gave me such a brilliant ideas
thank you
 
Upvote 0

Similar Threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…