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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:55:33+00:00 2026-06-10T07:55:33+00:00

I made an adapter for my ListView like so : SimpleAdapter adapter = new

  • 0

I made an adapter for my ListView like so :

SimpleAdapter adapter = new SimpleAdapter(this.getBaseContext(), listItem, R.layout.list_cell_icon, new String[] { "img", "title", "description" }, new int[] { R.id.img, R.id.title, R.id.description }) {

        @Override
        public boolean isEnabled (int position) {

            if(position == 1 || position == 2) {
                return false;
            }
            return true;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {

            View v = super.getView(position, convertView, parent);

            if(position == 1 || position == 2) {

                TextView tv = (TextView) v.findViewById(R.id.title);
                tv.setTextColor(Color.DKGRAY);
            }

            return v;
        }
    };

For now I have two items that I want to disable in the list and then I want to display the text in dark gray. My problem is that the text color in row at position 0 is changed to dark gray as well. How can it be ? Did I miss something?

  • 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-10T07:55:35+00:00Added an answer on June 10, 2026 at 7:55 am

    you need to add this :

    TextView tv = (TextView) v.findViewById(R.id.title);    
    if(position == 1 || position == 2) {
        tv.setTextColor(Color.DKGRAY);
    } else {
        tv.setTextColor(Color.WHITE);
    }
    

    The reason is that getView is called several times, not necesarly in a particular order, and getView recycle views. Hence, your TextView object is most likely always the same object. Therefore, you have to set back the color to the view. Or, you can use a state and a selected (like setEnabled(false) on the TextView)

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

Sidebar

Related Questions

So i have this listview with my custom XML file that i made for
i have a ListView for which i have made a custom adapter which extends
I've made my own custom adapter extended from BaseAdapter to show a listview and
I've made custom adapter and call notifyDataSetChanged() then data updates. But after call notifyDataSetChanged()
Made this nice little loop for hiding and showing div's, works as a charm
Made a custom obj called Item with some string fields and one float. .h
I have made a Spinner in Android: category = (Spinner) findViewById(R.id.ev_category); category.setOnItemSelectedListener(new MyOnItemSelectedListener()); ArrayAdapter<CharSequence>
I declare this adapter: ArrayAdapter<Problem> adapter; I also declare this this ArrayList: ArrayList<Problem> problems
I have multiple String arrays in my program (of which i have made individual
I have made a custom adapter class here is the code public class CustomArrayAdapterForReceipts

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.