Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 928167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:58:00+00:00 2026-05-15T19:58:00+00:00

I defined a white color in mycolors.xml under res/values as below: <?xml version=1.0 encoding=utf-8?>

  • 0

I defined a white color in mycolors.xml under res/values as below:

<?xml version="1.0" encoding="utf-8"?>
<resources> 
<color name="my_white">#ffffffff</color>
</resources>

In my code, I set the text color of a TextView as the white color I defined:

TextView myText = (TextView) findViewById(R.id.my_text);
myText.setTextColor(R.color.my_white);

But the text in the TextView turned out to be a black color.

When I use @color/my_white in layout xml files, it works fine.

I check the generate R.java, and see:

public static final int my_white=0x7f070025;

Did I miss something?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:58:01+00:00Added an answer on May 15, 2026 at 7:58 pm

    R.color.my_white is an ID that contains a reference to your resource. setTextColor expects you pass a color, not a reference. The code compiles and gives no errors because setTextColor expect an int; but, of course, you are giving the wrong int. In this case, you will have to convert the reference to a integer that represents that color:

    Resources res = getResources();
    int color = res.getColor(R.color.my_white);
    myText.setTextColor(color);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The project is poorly defined: we are to write educational software for CS 111
I would like to write this as a user defined function: private double Score(Story
I got this doubt while writing some code. Is 'bool' a basic datatype defined
I defined a record named log . I want to create an mnesia table
User-Defined Functions & Collating Sequences Full support for user-defined functions and collating sequences means
CSS background-color is giving me problems. The style block needs to use .land.custom_one instead
the pixman image library can draw radial color gradients between two circles. I'd like
I have a JavaFX applet with the stage's initial height and width defined as
I defined a dialog the following way: public void displayAvailableDevices(Vector<UserDevice> availableDevices) { connector.setDevicesFound(true); UserDevice[]
I am trying to make a class helper for the Color class in C#.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.