


Copy the following values in the strings.xml file:Ĭreate a layout for the selected item of the spinner: create new layout file name color_spinner_layout.xml with CheckedTextView as a root element. The following shows a simple array called spinner_items. Attach the adapter to Spinner and setOnItemSelectedListener to Spinner.Ĭreate a Spinner element in your XML layout: write the following code in your XML file.Ĭreate ArrayList for the spinner: you’ll need data to display into the spinner as a dropdown list so for that you’ll need to create ArrayList for the spinner.Create the spinner adapter using the Spinner Adapter class and set the CheckedTextView layout as a spinner layout and TextView for the item of the dropdown list.Create a layout for the item of the dropdown list.Create a layout for the selected item of the spinner.Create a Spinner element in your XML layout.States.java public class States List data = Boolean int code ĪllStates.java public class AllStates String String name ĬalenderFragment.Follow these steps to change the color of the spinner. In spinner state name is showing successfully but I want to gets corresponding state name id that I have in POJO class and not item position.

In spinner I am showing state name, but on select state it should select corresponding state name id that I have fetched from the server.

There are 2 values I am fetching from the server one is state name and other is state id. I am using spinner in my app I am populating spinner with the data fetching from the server.I am using Retrofit2 as a networking library.
