How can an error message be set for the Spinner in Android?

前端 未结 4 1029
借酒劲吻你
借酒劲吻你 2021-01-30 20:18

I\'d like to be able to call code like this, similar to how setError is set on a TextView:

spinner.setError(\"Error message\");

Ho

4条回答
  •  滥情空心
    2021-01-30 21:02

    Spinner class will return a textview when you use getSelectedView(). So you can use setError() indirectly.

    ((TextView)spinner.getSelectedView()).setError("Error message");
    

    Results should be like ...

    setError in spinner

    Hope It will be helpful!

提交回复
热议问题