Search code examples
androidlayoutstylesspinnertextcolor

How to change the color of the selected item of a spinner


how to change the text color of the spinner, the text which is on the left side of the dropdown button? ("Denmark" in the picure)

enter image description here


Solution

  • You have to try like this

    public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
       TextView selectedText = (TextView) parent.getChildAt(0);
       if (selectedText != null) {
          selectedText.setTextColor(Color.RED);
       }
    }