Android Question [B4X] pfdialog more than 2 options at showdialog... and other needs... :-)

Magma

Well-Known Member
Licensed User
...It is not so question... is more like "want that too" or needing...

+at pfdialog:
So at the new library that create forms on the fly... i need... perhaps other needing too

1) have more than 2 options at showdialog... 3 or more ? (like that DELETE, OK, CANCEL) Delete needed for deleting record... (can be ignore for showdialog or something...)

2) When adding boolean may be need by default to be true... have the option to set it... (at formbuilder)

3) need to have the option somehow to be multilingual / so by default using... localizator or somehow... tell how to do that... :)

4) Have the form in ScrollPane/scrollview - if it is big...

5) Have decimal (choosing "," or ".") field and choosing max decimails (2,3,4,5) ... good for currency...

Keep on doing things like these...!!!!

ps: It was something that thinking to do it... because writing code for forms always boring :) actually before one year created an app like this at b4j (don't know if somehow helps - i am having a scrollpane technique that may be uses for forms):

it was using sql database/table/current rec... and saving at sql directly..

B4X:
Sub Class_Globals
    Private fx As JFX
    Private frm1 As Form
    Private ScrollPane1 As ScrollPane
    Private saveit As Button
    Private cancelit As Button
    Private Pane1 As Pane
  
    Dim y As Int
    Dim wtype As Int=0
    Dim fid As String
    Dim scrolly As Int=40

End Sub

Public Sub Initialize(Parent As Form)
    frm1.Initialize("frm",600dip,600dip)
    frm1.Resizable=True
    frm1.RootPane.LoadLayout("newform")
    frm1.SetFormStyle("UTILITY")
    frm1.Title=Main.formtitle
          
    frm1.SetOwner(Parent)
  
    ScrollPane1.LoadLayout("newpane",-1, scrolly)

    y=10
 
    'takes from main:
    'formtitle is the Title of current form...
    'recnow is the current rec of data table / sql
    'tablenow is table of sql table that will use...
    'formjob string set out of this module...
      
Select Case Main.formjob

Case "..."
    createtextfield("username:","username",False,False)
    createtextfield("password:","password",False,True)
    createdatefield("last date login:","edate",True)
    createtextfield("last time login:","etime",False,True)
    createcheckfield("loggded?:","logged", True)
    createcheckfield("admin?:","isadmin", True)
    createcheckfield("Is it a caller?:","calls", True)
    createcheckfield("Can manage points?:","points", True)
    readfields

'...other cases... / other forms...
End Select
  
  

    ScrollPane1.innernode.SetSize(Pane1.Width,scrolly)
  
End Sub

Sub createcheckfield(lbl As String,fieldname As String, isenabled As Boolean)
    Dim mylabel As Label
    mylabel.Initialize("mylbl"&y)
    mylabel.Text=lbl
    CSSUtils.SetStyleProperty(mylabel,"-fx-alignment","center-left")
    Dim mytext As CheckBox
    mytext.Initialize("mytxt"&y)
    mytext.Text=""
    mytext.Tag=fieldname
    If isenabled=False Then
        mytext.Enabled=False
    End If
    Pane1.AddNode(mylabel,10,y,250,25)
    Pane1.AddNode(mytext,270,y,280,25)
    y=y+35
    scrolly=scrolly+35

  
End Sub


Sub createtextfield(lbl As String,fieldname As String,no As Boolean, isenabled As Boolean)
    Dim mylabel As Label
    mylabel.Initialize("mylbl")
    mylabel.Text=lbl
    CSSUtils.SetStyleProperty(mylabel,"-fx-alignment","center-left")
    Dim mytext As TextField
    mytext.Initialize("mytxt")
    mytext.PromptText=""
    mytext.Tag=fieldname
    If no=True Then
        CSSUtils.SetStyleProperty(mytext,"-fx-alignment","center-right")
    End If
    If isenabled=False Then
        mytext.Enabled=False
    End If
    Pane1.AddNode(mylabel,10,y,250,25)
    Pane1.AddNode(mytext,270,y,280,25)
    y=y+35
    scrolly=scrolly+35

End Sub

Sub createdatefield(lbl As String,fieldname As String, isenabled As Boolean)
    Dim mylabel As Label
    mylabel.Initialize("mylbl")
    mylabel.Text=lbl
    CSSUtils.SetStyleProperty(mylabel,"-fx-alignment","center-left")
    Dim mytext As DatePicker
    mytext.Initialize("mytxt")
    mytext.Tag=fieldname
    If isenabled=False Then
        mytext.Enabled=False
    End If
    Pane1.AddNode(mylabel,10,y,250,25)
    Pane1.AddNode(mytext,270,y,280,25)
    y=y+35
    scrolly=scrolly+35

End Sub

Public Sub Show As String
    frm1.showandwait

    Return "OK"
End Sub

Sub frm_CloseRequest (EventData As Event)
    'EventData.Consume
End Sub

Sub saveit_Action
    Select Case Main.formjob

        Case "..."
           'here can run any calc... sub.
            Dim wvalues As String
            wvalues=getfields
            Log(wvalues)
            Main.sql1.ExecNonQuery("UPDATE users " & wvalues & " WHERE " & fid & "='" & Main.recnow & "';")
            cancelit_Action

'other cases...
    End Select
End Sub


Sub readfields
    Dim cur As ResultSet

    If IsNumber(Main.recnow)=True Then
        wtype=1 
    End If
  
    cur=Main.sql1.ExecQuery("SELECT * from " & Main.tablenow & ";")
    fid = cur.GetColumnName(0)
    cur.Close 


    If wtype=1 Then
    cur=Main.sql1.ExecQuery("SELECT * from " & Main.tablenow & " WHERE " & fid & "=" & Main.recnow & " LIMIT 1;")
    Else
    cur=Main.sql1.ExecQuery("SELECT * from " & Main.tablenow & " WHERE " & fid & "='" & Main.recnow  & "' LIMIT 1;")
    End If
  

    Do While cur.nextrow
    For Each n As Node In Pane1.GetAllViewsRecursive
      
        If n.Tag<>"" And n.Tag<>Null Then

        If n Is TextField Then
                Dim t As TextField = n
                If CSSUtils.GetStyleProperty(n,"-fx-alignment")="center-right" Then
                    For k=0 To cur.ColumnCount-1
                    If cur.GetColumnName(k)=n.Tag Then
                    t.Text= cur.GetString2(k)
                    Exit
                    End If
                    Next
                Else
                    For k=0 To cur.ColumnCount-1
                    If cur.GetColumnName(k)=n.Tag Then
                    t.Text= cur.GetString2(k)
                    Exit
                    End If
                    Next
                End If
      
        End If
      
        If n Is DatePicker Then
            Dim d As DatePicker=n
          
          
            Dim s As String = cur.GetString(n.Tag)
          
            If s=Null Then
                s=""
                Else
            d.DateTicks=DateTime.DateParse(s)
            End If
          
        End If
      
        If n Is CheckBox Then
            Dim c As CheckBox=n
            If cur.GetInt(n.Tag)=0 Then
                c.Checked=False
                Else
                c.Checked=True
            End If
                  
        End If
      
        End If

    Next
  
    Loop
  
    cur.close 
  
End Sub




Sub getfields As String
  
    Dim su As StringBuilder
    su.Initialize
  
    su.Append("SET ")
    Dim o As Int

    For Each n As Node In Pane1.GetAllViewsRecursive
      
        If n<>Null And n.Tag<>"" Then

        Log(n.Tag)

        If n Is TextField Then
            If n.Tag<>"" Then
            Dim t As TextField=n
            If t.text<>"" Then
                o=o+1
                If o>1 Then
                    su.Append(",")
                End If
            su.Append(n.tag & "=" )
            If CSSUtils.GetStyleProperty(n,"-fx-alignment")="center-right" Then
                su.Append(t.text)
            Else
                su.Append("'" & t.text &"'")
            End If
            End If
            End If
        End If
        If n Is DatePicker Then
            If n.Tag<>"" Then
            Dim d As DatePicker=n
                o=o+1
                If o>1 Then
                    su.Append(",")
                End If
                su.Append(n.tag & "='" & DateTime.Date(d.DateTicks) & "'" )
            End If
        End If
        If n Is CheckBox Then
            If n.Tag<>"" Then
            Dim c As CheckBox=n
                If c.checked=True Then
                    o=o+1
                    If o>1 Then
                        su.Append(",")
                    End If
                    su.Append(n.tag & "=1" )
                Else
                    o=o+1
                    If o>1 Then
                        su.Append(",")
                    End If
                    su.Append(n.tag & "=0" )
                End If
            End If
        End If
    End If
    Next
  
    Dim s As String
    s=su.ToString
    Log(s)
    Return s
  
End Sub

Sub cancelit_Action
    frm1.close
End Sub
 

Magma

Well-Known Member
Licensed User
Thanks !!

3) localizator in pfdialog - any example... must edit library ?
4) at b4a is scrollable ???? - because i think test it and wasnt :-(
5) if have number field... somehow mask it like this #0.00 and have this option if will with comma or period #0,00 or #0.00 and set the decimal number too #0.0000... actually mask/format the fields :) + have the option if will be right align... or left...
 
Top