Android Question How to set text color in a CustomView?

Discussion in 'Android Questions' started by Massy, Mar 17, 2015.

  1. Massy

    Massy Member Licensed User

    Hello, I'm using a CustomView with AutoTextSizeLabel, I would like to change the text color by code, but I don't know how to do it... I saw in the tread for AutoTextSizeLabel Erel said to someone that asked the same thing to change its tipe to Public, I did it but nothing changed and CustomView1.color = Colors.Red keep giving an error...
    How can I do it?
    Thanks for your help
    Massy
     
  2. stevel05

    stevel05 Expert Licensed User

    You need to change the text color for each child (label or AutoTextSizeLabel) or whatever you have in the custom listview. If this doesn't help post the code that you are using to create the CustomListView, it will make it easier to help.
     
  3. Massy

    Massy Member Licensed User

    I have a CustomView in the Designer panel named CustomView1 and it's "Custom Type" is setted on AutoTextSizeLabel.
    Then in my Action I declare the CustomView in Sub Globals: Public CustomView1 As AutoTextSizeLabel and in Sub Activity_Create I assign the color with: CustomView1 .color = Colors.Red
     
  4. stevel05

    stevel05 Expert Licensed User

    Sorry I misread the question, I thought you were asking about a CustomListView.

    To change the color of the label in the AutoTextSizeLabel you need to access the label it contains. You can add this sub to the AutoTextsizeLabel Class and it will change the color:

    Code:
    Public Sub setTextColor(color As Int)
        mLbl.TextColor = color
    End Sub
     
    koaunglay and DonManfred like this.
  5. Massy

    Massy Member Licensed User

    Thanks a lot Steve!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice