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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:06:39+00:00 2026-06-12T18:06:39+00:00

Hello i want to change default orange color to red while selecting list item

  • 0

Hello i want to change default orange color to red while selecting list item from spinner below is my code

To put Text in middle in spinner list and remove radio button in selection i have make custom adapter

   ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.range, R.layout.middle_text_spinner);
spBAFirst.setAdapter(adapter);

now xml file for middle_text_spinner is below…

<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
style="?android:attr/spinnerItemStyle"
android:singleLine="true" 
android:layout_width="fill_parent"
android:textColor="@color/tabDark"
android:layout_height="wrap_content"
android:gravity="center" />

Now Image of spinner is below

SPINNER

First of all i want to change color of this Middle text to white instead of black

but when the list open all the text must be BLACK and white background but in some phone text will become white

enter image description here

Now i want to change default color orange to RED while selecting the list

I have Googled but can not change color while selecting

i have tried with listSelector but it can not be done and used also below is my code

this is in drawable folder btn_red_color.xml file

 <?xml version="1.0" encoding="utf-8"?>
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
   <item android:state_enabled="false" android:state_focused="true"
    android:drawable="@color/red" />
   <item android:state_pressed="true"
    android:drawable="@color/red" />
   <item android:state_focused="true"
    android:drawable="@color/red" />
</selector>

and set this value to spinner listSelector

 <Spinner
  android:id="@+id/spBAFirst"
   style="@style/my_cust_text"
   android:layout_width="100dp"
   android:layout_height="35dp"
   android:background="@drawable/blue_button"
   android:listSelector="@drawable/btn_red_color" />

and my_cust_text style is

  <style name="my_cust_text">
    <item name="android:layout_width">0dp</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:ellipsize">marquee</item>
    <item name="android:lines">1</item>
    <item name="android:maxLines">1</item>
    <item name="android:layout_weight">1</item>
    <item name="android:entries">@+array/range</item>
    <item name="android:layout_marginLeft">-3dip</item>
    <item name="android:layout_marginRight">-3dip</item>
    <item name="android:gravity">center</item>
</style>    

but it is not working 🙁 please can any body help me

  • 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-12T18:06:41+00:00Added an answer on June 12, 2026 at 6:06 pm

    I have find solution by this way you can be surely do it 90% of your work 🙂 You can show RED highlighted color

    enter image description here

    make CustomAdapter called MySpinnerAdapter…

      MySpinnerAdapter adapter = new MySpinnerAdapter(MySettings.this);
      spBAFirst.setAdapter(adapter);
    
    
     static class ViewHolder {
        TextView text;
    }
    
    private class MySpinnerAdapter extends BaseAdapter {
    
        private LayoutInflater mInflater;
        String[] array;
    
        public MySpinnerAdapter(Context context) {
            mInflater = LayoutInflater.from(context);
            array = getResources().getStringArray(R.array.range);
        }
    
        @Override
        public int getCount() {
            return array.length;
        }
    
        @Override
        public Object getItem(int position) {
            return position;
        }
    
        @Override
        public long getItemId(int position) {
            return position;
        }
    
        // A view to hold each row in the list
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder holder;
    
            if (convertView == null) {
                convertView = mInflater.inflate(R.layout.middle_text_spinner, null);
                holder = new ViewHolder();
                holder.text = (TextView) convertView.findViewById(R.id.spinnerText);
                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
            holder.text.setText(array[position]);
            convertView.setBackgroundResource(R.drawable.btn_red_color);
            return convertView;
        }
    }
    

    put this file in drawable folder btn_red_color.xml

      <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
      <item android:state_enabled="false" android:state_focused="true"
        android:drawable="@color/white" />
      <item android:state_pressed="true"
        android:drawable="@color/red" />
      <item android:state_focused="true"
        android:drawable="@color/red" />
    </selector>
    

    Spinner’s xml file is like this

      <Spinner
                        android:id="@+id/spBAThird"
                        style="@style/my_cust_text"
                        android:layout_width="100dp"
                        android:layout_height="35dp"
                        android:background="@drawable/blue_button"
                        android:cacheColorHint="@color/red"
                        android:textColor="@color/white" />
    

    Middle_text_spinner.xml file is below

       <?xml version="1.0" encoding="utf-8"?>
     <TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/spinnerText"
    style="?android:attr/spinnerItemStyle"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:singleLine="true"
    android:textColor="@color/tabDark" />
    

    so enjoy 🙂

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

Sidebar

Related Questions

If i want to change the below Hello To: HELLO Its fine when i
Hello I'm new to Joomla and I want to change the way an account
I want to change the font color and size for 1 line in richTextBox
hello i'm writing a GM user script and i want to change the favicon
Question Answer below Hello I'm looking a simple way to change the colour of
Suppose I have a String, Hello World. I want to change the style of
I want to change a Form control property from a process thread event fire
I want to be able to change an XML node value from WiX. The
I want to change this string <p><b> hello world </b></p>. I am playing <b>
Hello I am having a alertview and i want to change the size by

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.