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 6123095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:58:32+00:00 2026-05-23T15:58:32+00:00

I created a colors.xml file in my Android app under /res/values/colors.xml. The contents are…

  • 0

I created a colors.xml file in my Android app under /res/values/colors.xml. The contents are…

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="Green">#00ff00</color>
</resources>

I try to update the background of my a TableRow using…

    TableRow test = (TableRow)findViewById(R.id.tableRow2);
    test.setBackgroundColor(R.color.Green);

This does not set it as green, it is gray instead. No matter what values I add to the colors.xml file, it is always the same gray color. However this does work…

    TableRow test = (TableRow)findViewById(R.id.tableRow2);
    test.setBackgroundColor(android.graphics.Color.GREEN);

Is something wrong with my colors.xml?

  • 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-23T15:58:32+00:00Added an answer on May 23, 2026 at 3:58 pm

    You should use this instead:

    TableRow test = (TableRow)findViewById(R.id.tableRow2);
    test.setBackgroundColor(getResources().getColor(R.color.Green));
    

    Its unfortunate that resource ID and color have same type: int. You should get color value from resources via getColor() and use that valu as color. While you are using resource ID as color.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use colors created in my res/values/colors.xml file. But when I
I am new to android. I created a main.xml file like <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent
In android, through xml parsing i have xml file values in tableview now which
I create simple style.xml file <style name=You.EditText.Style parent=@android:style/Widget.EditText> <item name=android:textColor>@color/colorRed</item> <item name=android:gravity>center</item> </style> But
I want to create an Android ImageButton in the xml file with a background
I am using the following code by the Android-people-XMLParsing example for parsing XML file
In my android app, I create thumbnails in xml this way: <ImageView android:id=@+id/my_thumbnail android:layout_width=50dp
I created a state-list selector file item_bg_selector.xml in the drawable folder like this :
Can I parse kml file in order to display paths or points in Android?
Updated to be clear. Step One: I have a XML file that I want

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.