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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:19:27+00:00 2026-05-21T22:19:27+00:00

I have a spinner in which I would like to have the text of

  • 0

I have a spinner in which I would like to have the text of each item be a different color. for example on item0 the text should be red, item1 the text should be blue, and item2 the text should be green. I tried setting the item I want to change to a textView and changing the color of the textview but it does not work that way. any ideas on how to acomplish this task?

              Spinner spinner = (Spinner) findViewById(R.id.spinner1);

              ArrayList<String> array = new ArrayList<String>();
              array.add("item0");
    array.add("item1");
    array.add("item2");

              ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this,R.layout.row, array);
              spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

               spinner.setAdapter(spinnerArrayAdapter)

              try{
    TextView tv = new TextView((Context) spinner.getItemAtPosition(0));
    tv.setTextColor(Color.argb(0, 255, 0, 0));  
    }catch(Exception e){
    Toast.makeText(getApplicationContext(), "Error: " + e.toString(), Toast.LENGTH_LONG);
        }
  • 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-21T22:19:28+00:00Added an answer on May 21, 2026 at 10:19 pm

    create your own class that extends BaseAdapter and implements SpinnerAdapter.

    Override getDropDownView, and as you process the position you can format the textview from a custom layout you inflate.

    @Override
    public View getDropDownView(int position, View convertView, ViewGroup parent){
    
        View v = convertView;
    
        if (v == null) {
            LayoutInflater vi = (LayoutInflater) mContext
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.your_custom_layout, null);
        }
        TextView tv=(TextView) v.findViewById(R.id.yourTextViewFromYourLayout);
        tv.setText(yourArrayList.getItem(position));
        switch (position) {
    case 0:
     //set tv's color here...
     break;
    case 1:
     //set tv's color here...
    etc...
    default:
     //set default color or whatever...
    }       
            return v;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have a spinner for which I would like to change its entry.
Here's the setup. I have a spinner, and each item in the spinner is
I have a list of values in my XML file which I would like
I want to implement the below: A spinner which would have a custom layout,
I have created a spinner which looks like My layout file is: <RelativeLayout android:layout_width=fill_parent
How can I modify the text color of the selected item on a Spinner
I'd really like my app to have a Spinner which stretches the entire length
I have created an application for ContactsContract... I have created a spinner which brings
I have an activity with a spinner which loads a simpleCursorAdaptor. I call another
I have a spinner witch is populated from database, when I select an item

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.