Android Question B4XFloatTextField cannot change fields parameters when field is used in custom view class


Active Member
Licensed User

I am making a revised B4XFloatTextField called tfeCustom. I have done the following:

  1. Created a layout (tfeCVLayout.bal) with a B4XFloatTextField called tfe and a toolbar of images for clear, back, forward, format title (proper, lowercase, uppercase, camel and SQLite SQL format
  2. Load the layout in my tfe class
  3. Created a test activity (Layout.Bal) that includes and instance of my new tfe class
  4. Modify parameters of the toolbar and tfe based on user input in the designer for Layout.Bal
The toolbar parameters get updated, but the tfe parameters (Hint Text, Hint Colors etc) do not update on the screen although even though they are being changed when you examine them in the debugger they are not getting

I tried;
but it doesn't fix the problem.

Here is the code:

tfe Class Initialization and Parameter code:
'Custom View class
#Event: ExampleEvent (Value As Int)
#DesignerProperty: Key: tfeToolbarHeightKey,             DisplayName: TFE Toolbar Hight,             FieldType: Int,         DefaultValue: 20,         Description: Height of edit field toolbar.
#DesignerProperty: Key: tfeToolbarWidthKey,              DisplayName: TFE Toolbar Width,             FieldType: Int,         DefaultValue: 150,         Description: Width of edit field toolbar.
#DesignerProperty: Key: tfeToolbarBtnWidthKey,          DisplayName: TFE Toolbar Button Width,         FieldType: Int,         DefaultValue: 20,         Description: Width of edit field toolbar buttons.

#DesignerProperty: Key: tfeHintTextKey,                  DisplayName: Hint Text,                     FieldType: String,         DefaultValue: Hint,         Description: Hint Text.
#DesignerProperty: Key: tfeHintTextFcsdColorKey,          DisplayName: Hint Focussed Color,             FieldType: Color,         DefaultValue: 0xFF708F69,     Description: Focussed Hint Color.
#DesignerProperty: Key: tfeHintTextNonFcsdColorKey,      DisplayName: Hint Non Focussed Color,         FieldType: Color,         DefaultValue: 0xFFA1C49A,     Description: Non Focussed Hint Color
#DesignerProperty: Key: tfeHintTextFcsdFontSizeKey,      DisplayName: Hint Focussed Font Size,         FieldType: Int,         DefaultValue: 10,             Description: Focussed Font Size.
#DesignerProperty: Key: tfeHintTextNonFcsdFontSizeKey,  DisplayName: Hint Non Focussed Font Size,     FieldType: Int,         DefaultValue: 14,             Description: Non Focussed Font Size.

#DesignerProperty: Key: tfeTextFontSizeKey,              DisplayName: Text Font Size,                 FieldType: Int,         DefaultValue: 14,             Description: Text field font size
#DesignerProperty: Key: tfeTextFontColorKey,              DisplayName: Text Font Color,                 FieldType: Color,         DefaultValue: 0xFF000000,     Description: Text field font color
#DesignerProperty: Key: tfeTextFontStyleKey,              DisplayName: Text Style,                     FieldType: String,         DefaultValue: NORMAL,         List: NORMAL|BOLD|ITALIC|BOLD_ITALIC

#DesignerProperty: Key: KeyboardType, DisplayName: Keyboard Type, FieldType: String, List: Text|Numbers|Decimal, DefaultValue: Text

Sub Class_Globals
#IgnoreWarnings: 9
    Private mEventName                     As String 'ignore
    Private mCallBack                     As Object 'ignore
    Private mBase                         As Panel
    Private xui                         As XUI 'ignore
    Private Const DefaultColorConstant     As Int = -984833 'ignore

    Private btnPanel     As B4XView
    Private imgClear     As B4XView
    Private imgProper     As B4XView
    Private imgUndo     As B4XView
    Private imgRedo     As B4XView
    Private btnPanel As B4XView

    Private tfe As B4XFloatTextField
    Private tfePanel                 As B4XView
    Private tfeToolbarBtnWidth         As Int
    Private toolBarBtnClearEvent     As Boolean
    Private toolBarBtnUndoEvent     As Boolean
    Private toolBarBtnRedoEvent     As Boolean
    Private toolBarBtnProperEvent     As Boolean
End Sub

Public Sub Initialize (Callback As Object, EventName As String)
    mEventName = EventName
    mCallBack = Callback

    capsState = 1
    textStringInitial = ""

    #if B4J
    #Else If B4i
    FeedbackGenerator = FeedbackGenerator.Initialize("UIImpactFeedbackGenerator").RunMethod("alloc", Null).RunMethod("initWithStyle:", Array(0)) 'light
    #End If   
End Sub

#IgnoreWarnings: 12
Sub DesignerCreateView (Base As Panel, Lbl As Label, Props As Map)
    mBase = Base
'    LastBaseHeight = mBase.Height
    Tag = mBase.Tag : mBase.Tag = Me
    LayoutLoaded = False
    tfe.Tag = "tfe"

    LayoutLoaded = True

    'Get parameters and set objects
    ' Mini toolbar for tfe B4XFloatTextField
    ' ********  All of these get updated on the screen  *********
    btnPanel.Height     = IntToDIP(Props.GetDefault("tfeToolbarHeightKey", 15dip))
    btnPanel.Width         = IntToDIP(Props.GetDefault("tfeToolbarWidthKey", 150dip))
    tfeToolbarBtnWidth     = IntToDIP(Props.GetDefault("tfeToolbarBtnWidthKey", 15dip))
    imgClear.Width         = tfeToolbarBtnWidth
    imgUndo.Width        = tfeToolbarBtnWidth
    imgProper.Width     = tfeToolbarBtnWidth
    imgRedo.Width        = tfeToolbarBtnWidth
    imgClear.Height     = btnPanel.Height
    imgUndo.Height        = btnPanel.Height
    imgProper.Height     = btnPanel.Height
    imgRedo.Height        = btnPanel.Height
    ' *************************************************************
    ' B4XFloatTextField set parameters
    ' ********  None OF the following update the screen  *********
    tfe.HintText             = Props.GetDefault("tfeHintTextKey", "Hint")
    tfe.HintColor            = Props.GetDefault("tfeHintTextFcsdColorKey", 0xFF708F69)
    tfe.NonFocusedHintColor = Props.GetDefault("tfeHintTextNonFcsdColorKey", 0xFFA1C49A)
    tfe.LargeLabelTextSize =  Props.GetDefault("tfeHintTextFcsdFontSizeKey", 10)
    tfe.SmallLabelTextSize =  Props.GetDefault("tfeHintTextNonFcsdFontSizeKey", 14)
    tfe.HintLabelSmallOffsetY = -1dip
    tfe.TextField.TextColor    = Props.GetDefault("tfeTextFontColorKey", 0xFF000000)

    setTextFontSizeAndStyle(Props.GetDefault("tfeTextFontStyleKey", "NORMAL"), _
                            Props.GetDefault("tfeTextFontSizeKey", 14))
    ' *************************************************************
End Sub


    21.5 KB · Views: 71


Active Member
Licensed User

Found the answer after looking at the source file for the B4XFloatTextField tfe.Update method does the trick.

It' a pity its not called HintUpdate as I would have picked it up in code completion. As it only updates the hint HintUpdate would mean something specific. This would have saved me two hours of messing around.

Best regards
Upvote 0