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

The Archive Base Latest Questions

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

For my application i retrieve a number from the database. When the activity starts

  • 0

For my application i retrieve a number from the database. When the activity starts up it has to show the number in a different color then the other numbers in the list.

After retrieving the data from the database this is my code:

int row = 5;
TextView child = (TextView)ListView.GetChildAt(row);
child.SetTextColor(Color.Red);

This code was placed in the OnCreate function. I kept getting a null value back for the child textview. I then found out that the reason for the null value is that in the OnCreate function the listview still needs to be rendered. I then moved the code to the OnStart() function but this didn’t work either.

Can anyone tell me how I should retrieve the child row from the listview during the creation/start of the activity?

  • 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-27T09:23:58+00:00Added an answer on May 27, 2026 at 9:23 am

    even if you will be able to do it this way you will experience problems with this view getting recycled .. (you will see other views getting colored with red when you scroll up and down).
    You need to override your adapter and set the view’s color in the position you want
    under getView() –

    TextView myText = (TextView) view.findViewById(R.Id ....
    if (pos==5)
        myText.setTextColor(Color.Red);
    else 
        myText.setTextColor(Color.Black); //original color..
    

    EDIT:

    you don’t need to have a custom xml. if you find android’s xml you can find its id. I believe its android.R.id.text1 . so your adapter should look something like

    myAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1) {
                     @Override
                     public View getView(int position, View v, ViewGroup parent) {
                         if (v == null) {
                                LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                                v = inflater.inflate(android.R.layout.simple_list_item_1, null);
                            }
                         View view = super.getView(position, v, parent);
                         if (position==5)
                             view.setTextColor(Color.Red);
                         else 
                             view.setTextColor(Color.Black); //original color..
     }
     myList.setAdapter(myAdapter);
    

    not sure I got it all right but something like that..
    hope it helps.

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

Sidebar

Related Questions

I'm building an application in Java to retrieve data from MySQL database. After executing
In my application,I retrieve a timestamp from the table which is of the format
The application that I'm designing will retrieve and store content from a variety of
In my C# 2008 application, I use the SerialPort.GetPortNames() function to retrieve the list
I have an application that uses incident numbers (amongst other types of numbers). These
I'm trying to pass a build number from Hudson into a Flex application. I've
I have to develop a layer to retrieve data from a database (can be
In my application I generate CheckBoxes for each possible category (retrieved from a database)
I´m deploying a small Silverlight application, which consumes data from a WCF DataService then
ASP .NET MVC2 application. Site.Master file contains number of ul list link names, url

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.