

To run the app from android studio, open one of your project's activity files and click Run icon from the toolbar. Step 2 Add the following code to res/layout/activitymain.xml. Step 1 Create a new project in Android Studio, go to File New Project and fill all required details to create a new project. I assume you have connected your actual Android Mobile device with your computer. This example demonstrates how to make an Android Spinner with initial default text using Kotlin. Step 4 – Add the following code to androidManifest.xml Step 4 – Create a layout resource file and add the following code − Public class MainActivity extends AppCompatActivity ĪrrayAdapter arrayAdapter = new ArrayAdapter(this,ĪtDropDownViewResource(R.layout.spinner_list)

Step 3 − Add the following code to src/MainActivity.java import 7.app.AppCompatActivity Step 2 − Add the following code to res/layout/activity_main.xml. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. private OnItemSelectedListener OnCatSpinnerCL = new AdapterView.This example demonstrates how do I change the spinner textSize and textColor in android. That's why it can intercept the creation of views in drop down list and change text color to whatever color is needed. This.mAdapter = new CustomArrayAdapter(this, spin_arry) īecause CustomArrayAdapter knows that we use android's built-in layout resource, it also knows that text will be placed in TextView with id android.R.id.text1. Then you create adapter in your code like this: String spin_arry = getResources().getStringArray(R.array.Planets) tTextColor(Color.RED) //choose your color :)

TextView text = (TextView)view.findViewById(android.R.id.text1) we know that simple_spinner_item has android.R.id.text1 TextView: View view = super.getView(position, convertView, parent) other View getDropDownView(int position, View convertView, ViewGroup parent)

Super(ctx, android.R.layout.simple_spinner_item, objects) Public CustomArrayAdapter(Context ctx, T objects) I'm going to use Spinner project sample from Android SDK for next code examples.įirst, you need to create you custom adapter which will intercept the creation of views in drop down list: static class CustomArrayAdapter extends ArrayAdapter
