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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:50:28+00:00 2026-05-28T01:50:28+00:00

I am using Jeff Sharkey’s SeparatedListAdapter and I would like to set the text

  • 0

I am using Jeff Sharkey’s SeparatedListAdapter and I would like to set the text color, but I’m not sure how.

To give you some background on his adapter, he subclassed a BaseAdapter similar to a simple Android list. So, I tried to set the text color in the getView() method like this (Your can see my attempt in between the commented section):

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

    ViewHolder holder;

    int sectionnum = 0;
    for(Object section : this.sections.keySet()) {
        Adapter adapter = sections.get(section);
        int size = adapter.getCount() + 1;



        // check if position inside this section
        if(position == 0) return headers.getView(sectionnum, convertView, parent);
        if(position < size)
        {
            /***** I added this section to try to set the text color ***/

            TextView captionTV = (TextView)adapter.getView(position, convertView, parent).findViewById(R.id.list_complex_caption);
            captionTV.setTextColor(R.color.black;);

            TextView titleTV = (TextView)adapter.getView(position, convertView, parent).findViewById(R.id.list_complex_title);
            titleTV.setTextColor(R.color.black;);

            /***** end add *****/               

            return adapter.getView(position - 1, convertView, parent);
        }

        // otherwise jump into next section
        position -= size;
        sectionnum++;
    }
    return null;
}

But what happens is that it sets the text color for the first cell, but does not set it for the rest.

Any ideas?

  • 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-28T01:50:28+00:00Added an answer on May 28, 2026 at 1:50 am

    Hm. Nifty adapter.

    The first thing to note here – modifying Views in the way you’re doing is something best left to the layouts you use in the various section adapters, i.e. if you want black text, use an item layout that has black text.

    To do it in code anyway you should not repeatedly call #getView(int, View, ViewGroup) on the sub-section adapters, instead do like this:

    /**
     * {@inheritDoc}
     */
    public View getView(int position, View convertView, ViewGroup parent) {
        int sectionnum = 0;
        for(Object section : this.sections.keySet()) {
            Adapter adapter = sections.get(section);
            int size = adapter.getCount() + 1;
    
            // check if position inside this section
            if(position == 0) return headers.getView(sectionnum, convertView, parent);
            if(position < size){
                View view = adapter.getView(position - 1, convertView, parent);
                TextView captionTV = (TextView) view.findViewById(R.id.list_complex_caption);
                captionTV.setTextColor(R.color.black);
                TextView titleTV = (TextView) view.findViewById(R.id.list_complex_title);
                titleTV.setTextColor(R.color.black);
                return view;
            }
    
            // otherwise jump into next section
            position -= size;
            sectionnum++;
        }
        return null;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Jeff Atwood's Last Configuration Section Handler You'll Ever Need , but it
I am following an example project Sky by Jeff Sharkey using styles in my
I'm working on sanitizing my Html using Jeff Atwood's code found here But the
A few months ago I built some online samples like this one from Jeff
I'm using the XML data source feature in Reporting Services 2005 but having some
Jeff has previously blogged about using the cache to perform "out of band" processing
Jeff mentioned the concept of 'Progressive Enhancement' when talking about using JQuery to write
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I have a blender image exported using Jeff LaMarche .h export script. I am

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.