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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:20:07+00:00 2026-05-29T11:20:07+00:00

Good evening StackOverflow This time I’m fighting with a ListView Containing TextViews. I add

  • 0

Good evening StackOverflow

This time I’m fighting with a ListView Containing TextViews.

I add an OnItemClick Listener.

    v.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
            TextView tvItm = (TextView) arg1;
            int Col = tvItm.getTextColors().getDefaultColor();
            if (Col == Color.WHITE)
                tvItm.setTextColor(Color.GREEN);
            else
                tvItm.setTextColor(Color.WHITE);
        }
    });

As you can see I toggle the color of the text, and it works.. BUT, it works on several items at a time, even though i only click one item. So when I click the first item, it turns green, then there’s six white items, and the 7th item is green, but i never clicked the 7th item!!

item1 – clicked – green
item2 – not clicked – white
item3 – not clicked – white
item4 – not clicked – white
item5 – not clicked – white
item6 – not clicked – white
item7 – not clicked – green
item8 – not clicked – white
item9 – not clicked – white
etc…

And that pattern continues for all of the list.

Additionally, if I flick/move the list up and down fast, the pattern shitfs up or down with 1 to 2 items.

Here’s a screenshot:
List Problem

First image: Nothing is done
Second image: I clicked ‘AK Kusine’
Third image: I scroll down, and ‘Allan Malka’ is also changed..

If I set a breakpoint in the Listener it only stops once per click on the list.
What causes this behaviour? And more important, how can I fix it?

  • 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-29T11:20:07+00:00Added an answer on May 29, 2026 at 11:20 am

    This is because getView method recycle your views to optimize the performance.
    Implement the getView(int position, View convertView, ViewGroup parent)method in your adapter(so you need to extend an Adapter) in a way that it gets the convertView and makes it green or white according to the position..

    Watch this for detailed explanation. It may seem long but it’s very useful.

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

Sidebar

Related Questions

Good Evening, I am pretty new to Unix so maybe this mini project is
Good morning, afternoon, evening or night (depending on your timezone). This is just a
Good evening. For a project, I have to create a system. In this system,
Good evening fellow coders, and thank you in advance for any help/attention. This is
Good Evening All, I've created the following stored procedure: CREATE PROCEDURE AddQuote -- Add
Good evening stackoverflow. I have a problem involving JOptionPanes. Every so often they simply
Good Evening, I'm building a website which will will look something like this: So
Good evening :-)! I have this code to use Drag & Drop method for
Good evening! I'm developing a web application with asp.net C#. In this application the
Good evening :) I'm playing around with g++ and makefiles. I've gotten to this

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.