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

前端 未结 4 1017
借酒劲吻你
借酒劲吻你 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条回答
  •  梦毁少年i
    2021-01-30 21:24

    for people who are looking for a Kotlin answer

    val errorText = spinnerclient.selectedView as TextView
                    errorText.error = "client required"
                    errorText.requestFocus()
                    return@setOnClickListener
    

    The focus was returned but the text wasn't displayed. I will update once its displayed

提交回复
热议问题