Android Question Change All Text Properties of Edittext View dynamically in code

Good Day Sirs,
How to change all the Text properties of EditText View? Can it be declared/included in the Initialize() method also?

Thanks in Advance.😊
 

William Lancee

Well-Known Member
Licensed User
Longtime User
Initialize("") takes only one parameter, the event name. So not there.
By using B4XView as a wrapper for the EditText you can do all you need to do.

I tend to put this type of code in a Sub.

B4X:
'Include the XUI library and put Private xui as XUI in Processs_Globals

    Private et As EditText    'If created with designer you will have this in Globals
    et.Initialize("")        'If created with designer you don't need this
    et.Padding = Array As Int(10dip,0,0,0)

    Dim etx As B4XView = et
    etx.SetColorAndBorder(xui.Color_Blue, 1dip, xui.Color_Black, 5dip)
    etx.SetTextAlignment("CENTER", "LEFT")    'this is default
    etx.Font = xui.CreateDefaultFont(20)
    etx.TextColor = xui.Color_White
    etx.Text = "WOW"

'If created with designer, you don't need this  
    Root.AddView(etx, 300dip, 50dip, 200dip, 50dip)            'if B4XPages
'    Activity.AddView(etx, 300dip, 50dip, 200dip, 50dip)        'otherwise
 
Upvote 0
Initialize("") takes only one parameter, the event name. So not there.
By using B4XView as a wrapper for the EditText you can do all you need to do.

I tend to put this type of code in a Sub.

B4X:
'Include the XUI library and put Private xui as XUI in Processs_Globals

    Private et As EditText    'If created with designer you will have this in Globals
    et.Initialize("")        'If created with designer you don't need this
    et.Padding = Array As Int(10dip,0,0,0)

    Dim etx As B4XView = et
    etx.SetColorAndBorder(xui.Color_Blue, 1dip, xui.Color_Black, 5dip)
    etx.SetTextAlignment("CENTER", "LEFT")    'this is default
    etx.Font = xui.CreateDefaultFont(20)
    etx.TextColor = xui.Color_White
    etx.Text = "WOW"

'If created with designer, you don't need this  
    Root.AddView(etx, 300dip, 50dip, 200dip, 50dip)            'if B4XPages
'    Activity.AddView(etx, 300dip, 50dip, 200dip, 50dip)        'otherwise
Thank you Sir William for this help.😊
 
Upvote 0
Top