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

前端 未结 4 1027
借酒劲吻你
借酒劲吻你 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 20:57

    Here is a solution that uses a hidden TextView to get a pop-up message to appear, in addition to the error icon in the spinner. When in an error state, the Spinner looks like this:

    Spinner in invalid state

    When not in an error state, it looks like this.

    Spinner in valid state

    The complete solution is documented here: https://stackoverflow.com/a/29956372/3063884

提交回复
热议问题