Android Question B4xListTemplate View - change some aspect of internal views by code

Gianni Sassanelli

Active Member
Licensed User
Longtime User
Hi,
i'm usign B4x View in some new test project.

I need a few help for this 2 request
1) How can to know all view inserted into a B4xView and control It? For example in B4XListTemplate
2) Is possible to change by code some properties some font dimensions, aspect and other for rows of scrollview or other ?

My simply attached code is that i'm testing.
I need to enlarge to 100%x of view the gray part of list options
help me please

thanks


B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
        'These variables can only be accessed from this module.
    Private Dialog                 As B4XDialog
    Private XUI                 As XUI
    Private Causali_Fermo        As B4XListTemplate
    Private Base                 As B4XView
    Private BtnSHOW                As
End sub
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("lay_01")
    Base = Activity
    Dialog.Initialize (Base)
    Dialog.Title = "CAPTION della DIALOG"
End Sub
sub btnSHOW_click
  
    Causali_Fermo.Initialize
    Causali_Fermo.mBase.Height = 500dip
    Causali_Fermo.mBase.Width = 80%x
  
    Causali_Fermo.CustomListView1.AsView.Color = Colors.Cyan
    Causali_Fermo.CustomListView1.DesignerLabel.Width = 100%x
    Causali_Fermo.CustomListView1.AsView.Width = 100%x
    Causali_Fermo.mBase.Color = Colors.White
    Causali_Fermo.Options = Array("Opzione 1", "Opzione 2", "Opzione 3", "Opzione 4")
    Causali_Fermo.AllowMultiSelection = False
  
  
  
    Dialog.Title = $"Indicare la motivazione del Fermo Fase"$
    Wait For (Dialog.ShowTemplate(Causali_Fermo, "OK", "", "CANCEL")) Complete (Result As Int)

End Sub
 

Attachments

  • esempio.png
    esempio.png
    42.4 KB · Views: 77

Mahares

Expert
Licensed User
Longtime User
I need to enlarge to 100%x of view the gray part of list options
help me please
B4X:
Sub btnSHOW_click
    Causali_Fermo.Initialize
    Causali_Fermo.Resize(100%x, 90%y)
    Causali_Fermo.CustomListView1.AsView.Color = Colors.Cyan
    Causali_Fermo.CustomListView1.AsView.width=100%x
    Causali_Fermo.CustomListView1.AsView.Height=90%y
    Causali_Fermo.Options = Array("Opzione 1", "Opzione 2", "Opzione 3", "Opzione 4")
    Causali_Fermo.AllowMultiSelection = False
  
    Dialog.Title = $"Indicare la motivazione del Fermo Fase"$
    Dialog.ButtonsColor =xui.Color_Red    
    Wait For (Dialog.ShowTemplate(Causali_Fermo, "OK", "", "CANCEL")) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        Dialog.Show($"You selected: ${Causali_Fermo.SelectedItem}"$, "OK", "", "")
    End If
End Sub
I think both OK and Cancel button need to have the same background color
1696608121432.png

You can also use CSBuilder for the text and have something like this other screenshot:
1696608307225.png
 
Upvote 0

Gianni Sassanelli

Active Member
Licensed User
Longtime User
Thank's you Mahares
i have solved with attached few line of code

B4X:
Dialog.Title = $"Indicare la Causale del Fermo Fase"$
Dialog.ButtonsFont        = XUI.CreateDefaultFont(22)
Dialog.ButtonsTextColor    = Colors.White
Dialog.ButtonsHeight        = 50dip

    Dim rs As ResumableSub = Dialog.ShowTemplate(Causali_Fermo, "CONFERMA", "", "ANNULLA")
    Dim bp As B4XView=Dialog.GetButton(XUI.DialogResponse_Positive)
    bp.Width     = 200dip
    'bp.Height    = 100dip   
    bp.Left         = Dialog.Base.Width - 402dip
    bp.Color         = XUI.Color_RGB(0,160,32)
    bp.Text         = "SALVA e"&CRLF&"sospendi Fase"
    
    
    Dim bn As B4XView=Dialog.GetButton(XUI.DialogResponse_Cancel)
    bn.Width     = 200dip
    'bp.Height    = 100dip
    bn.Left         = Dialog.Base.Width - 201dip
    bn.Color     = XUI.Color_RGB(160,0,32)
    bn.Text         = "NON Salvare"&CRLF&"Resta nella FASE"
    
    
    Wait For (rs) complete (result As Int)
the result is ...
1696665703000.png
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
i have solved with attached few line of code
Since you declared the positive bp and negative bn buttons as B4XView, you can take advantage of the B4XView properties. You will not need right, left, width, color. It will be something like this:
B4X:
Dim bp As B4XView=Dialog.GetButton(xui.DialogResponse_Positive)
    bp.Text         = "SALVA e"&CRLF&"sospendi Fase"    
    bp.SetLayoutAnimated(0,200dip, 90%y, 200dip,60dip)    'adjust your dips to suit
    bp.SetColorAndBorder( xui.Color_RGB(0,160,32), 3dip, xui.Color_White, 4dip)
     
    Dim bn As B4XView=Dialog.GetButton(xui.DialogResponse_Cancel)
    bn.Text         = "NON Salvare"&CRLF&"Resta nella FASE"   
    bn.SetLayoutAnimated(0,401dip, 90%y, 200dip,60dip)  'adjust your dips to your suit
    bn.SetColorAndBorder( xui.Color_RGB(160,0,32), 3dip, xui.Color_White, 4dip)
1696676961715.png
 
Upvote 0

Gianni Sassanelli

Active Member
Licensed User
Longtime User
Since you declared the positive bp and negative bn buttons as B4XView, you can take advantage of the B4XView properties. You will not need right, left, width, color. It will be something like this:
B4X:
Dim bp As B4XView=Dialog.GetButton(xui.DialogResponse_Positive)
    bp.Text         = "SALVA e"&CRLF&"sospendi Fase"   
    bp.SetLayoutAnimated(0,200dip, 90%y, 200dip,60dip)    'adjust your dips to suit
    bp.SetColorAndBorder( xui.Color_RGB(0,160,32), 3dip, xui.Color_White, 4dip)
    
    Dim bn As B4XView=Dialog.GetButton(xui.DialogResponse_Cancel)
    bn.Text         = "NON Salvare"&CRLF&"Resta nella FASE"  
    bn.SetLayoutAnimated(0,401dip, 90%y, 200dip,60dip)  'adjust your dips to your suit
    bn.SetColorAndBorder( xui.Color_RGB(160,0,32), 3dip, xui.Color_White, 4dip)
View attachment 146671
i try it
 
Upvote 0

Gianni Sassanelli

Active Member
Licensed User
Longtime User
Since you declared the positive bp and negative bn buttons as B4XView, you can take advantage of the B4XView properties. You will not need right, left, width, color. It will be something like this:
B4X:
Dim bp As B4XView=Dialog.GetButton(xui.DialogResponse_Positive)
    bp.Text         = "SALVA e"&CRLF&"sospendi Fase"   
    bp.SetLayoutAnimated(0,200dip, 90%y, 200dip,60dip)    'adjust your dips to suit
    bp.SetColorAndBorder( xui.Color_RGB(0,160,32), 3dip, xui.Color_White, 4dip)
    
    Dim bn As B4XView=Dialog.GetButton(xui.DialogResponse_Cancel)
    bn.Text         = "NON Salvare"&CRLF&"Resta nella FASE"  
    bn.SetLayoutAnimated(0,401dip, 90%y, 200dip,60dip)  'adjust your dips to your suit
    bn.SetColorAndBorder( xui.Color_RGB(160,0,32), 3dip, xui.Color_White, 4dip)
View attachment 146671
It's good.

Can i can ask you another question?
Can I close the dialog only if user click on RED button (OK) and do not close automatically if user click on one option if AllowMultiSelection is setted to FALSE?
 
Upvote 0
Top