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

  • Home
  • SEARCH
  • 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 8043193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:49:38+00:00 2026-06-05T04:49:38+00:00

i have a listview which is generated via a custom cursoradapter everything is working

  • 0

i have a listview which is generated via a custom cursoradapter

everything is working fine, except when i scroll up and down through the list, some of the textview’s are changing to GREEN randomly.

heres my code which generates the listview:

private class AchievementAdapter extends CursorAdapter {
    public AchievementAdapter(Context context, Cursor c) {
        super(context, c);
    }

    @Override
    public void bindView(View v, Context context, Cursor cursor) {
        TextView tv = (TextView) v.findViewById(R.id.achView1);

        if(cursor.getString(cursor.getColumnIndex("completed")).equals("yes")) {
            tv.setText(cursor.getString(cursor.getColumnIndex("name"))+" (completed)");
            tv.setTextColor(Color.GREEN);
        }
        else {
            tv.setText(cursor.getString(cursor.getColumnIndex("name")));
        }
    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View v = inflater.inflate(R.layout.achievements_item, parent, false);
        return v;
    }
}    

i read something about setcachecolorhint, but the method does not apply to a textview. how do i fix this so it stops changing textview colors randomly when i scroll?

  • 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-06-05T04:49:39+00:00Added an answer on June 5, 2026 at 4:49 am

    You should set textView color to normal in the else statement like:

    @Override
    public void bindView(View v, Context context, Cursor cursor) {
        TextView tv = (TextView) v.findViewById(R.id.achView1);
    
        if(cursor.getString(cursor.getColumnIndex("completed")).equals("yes")) {
            tv.setText(cursor.getString(cursor.getColumnIndex("name"))+" (completed)");
            tv.setTextColor(Color.GREEN);
        }
        else {
            tv.setText(cursor.getString(cursor.getColumnIndex("name")));
            tv.setTextColor(Color.BLACK); // Set your textview color as you need
        }
    }
    

    Hope this helps

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

Sidebar

Related Questions

I have a listview which contains N no. of items. When user scroll down
I have a ListView which potentially contains thousands of rows, generated by a CursorAdapter.
I have a ListView which contains custom rows. This custom row has following UI
I have a list of places in listview which i got from parsing JSON.
I have a list view which is populated via records from the database. Now
I have a problem with listview which list item contain a checkbox. When i
I have a listview which is filled with data form sqlitedatabase. A list-view element
I have ListView which is saving all data to database. For adding i have
I have a ListView which is using a GridView to display a DataTable and
I have a listview which has its datasource changed after update of a search

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.