Android Question B4XFloatTextField changing the text colour crashes app

nickt

Member
I know I'm new to this so it is probably something I have done but my main test program crashes when trying to set the text colour so I created this simple app also with wait for messages but it still crashes.

Thanks for any help.
 

Attachments

  • test.zip
    10.4 KB · Views: 72

Sagenut

Expert
Licensed User
Longtime User
Try this
B4X:
Private Sub Button3_Click
'    B4XFloatTextField1.mBase.TextColor = Colors.Green
    Dim MyText As B4XView = B4XFloatTextField1.TextField   'Set a reference as B4XView to B4XFloatTextField
    MyText.TextColor = Colors.Green   'Change the TextColor
End Sub
 
Upvote 0

zed

Active Member
Licensed User
Hi,

The code is not correct.

Here is :
B4X:
Private Sub Button3_Click
    B4XFloatTextField1.mBase.GetView(0).TextColor = Colors.Green
End Sub

Private Sub Button4_Click
    xui.MsgboxAsync ("Change text colour"  , "B4X")
    wait for msgbox_result
    B4XFloatTextField1.mBase.GetView(0).TextColor = Colors.DarkGray
End Sub
 

Attachments

  • B4XMainPage.bas
    1.5 KB · Views: 67
Upvote 0

nickt

Member
Thanks for the responses. Both work fine, in B4A color (background) would work but not in B4J where I tried it next and got it working with your help and the code below. With views(0 it seems to work well as a global so that cuts down on the typing in a larger project ...

B4X:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private B2 As B4XView 'button
    Private B3 As B4XView 'button
    Private BT1 As B4XFloatTextField
    Dim btv1 As B4XView
    Dim ccya, cblk , cblu,  ctrs As Int
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    btv1=BT1.mBase.GetView(0)
    ccyan = xui.color_cyan
    cblk = xui.Color_Black
    cblu = xui.Color_Blue
End Sub

Private Sub B2_Click
    btv1.Color =     cblk
    btv1.TextColor =     ccya
    B3.Color=ctrs
End Sub

Private Sub B3_Click
    Dim btv2 As B4XView = BT1.TextField
    btv2.Color = ccya
    btv2.TextColor = cblu
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…