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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:44:27+00:00 2026-05-30T04:44:27+00:00

I have seen some links which am not able to trace it out.I am

  • 0

I have seen some links which am not able to trace it out.I am trying to change the color of the list item using java code in my activity class. Iam not using any Code for list view in my XML file. So, please Can any one tell me how to change the color of the list item from default white to black and here is my sample code .

ListView listView;
// Create an array of Strings, that will be put to our ListActivity
String[] names = new String[] { "India", "Malaysia" };
// Use your own layout and point the adapter to the UI elements which
// contains the label
TextView tv = new TextView(getApplicationContext());
        tv.setText("Select Country");

        listView = getListView();
        listView.addHeaderView(tv);
       listView.setCacheColorHint(Color.rgb(36, 33, 32));
        listView.setBackgroundColor(Color.rgb(225, 243, 253));

        this.setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_expandable_list_item_1,names));

}

Thanks in advance

  • 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-30T04:44:28+00:00Added an answer on May 30, 2026 at 4:44 am

    I don’t think that changing the code in core Android components is a good idea. If you want to try something along the lines suggested by krishna5688, a better idea would probably be to better to create your own simple_expandable_list_item_1.xml (I would suggest giving it a more relevant name).
    The SDK version of the layout file can be found in <your SDK folder>\platforms\android-<whichever version you're using>\data\res\simple_expandable_list_item_1.xml.
    Put the contents into an xml file in your own res/layout folder, and make the changes there.
    Then change the line of code

        this.setListAdapter(new ArrayAdapter<String>(this,R.layout.<whatever you named your list item>,names));
    

    Note that it’s no longer android.R.layout…

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

Sidebar

Related Questions

I have seen some mails which has HTML content embedded in them. The content
i have seen some hand rolled solutions but does jquery out of the box
I have seen some links that tells how to use web client but one
I have seen some links that tells how to use web client but one
Have seen some similar questions: What is the difference between a JavaBean and a
I have seen some people in SO commenting that Singleton Pattern is an anti-pattern.
I have seen some related questions but none focusing on the specific problem I
I have seen some instances where people will say you have to use JS
I have seen some developers use the return statement in a catch block. Why/when
I have seen some of the other answers on this topic but dont really

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.