我搜索大量互聯網上關於我如何能在與科特林Android的使用上editText(s)
setFocusable()
,setText()
,setError()
等等等等方法(我知道的事實,我們可以使用在Java中上述方法),但我無法找到確切的解決方案,將爲我工作。如何在android系統與科特林
我使用 1)排球的HTTP調用 2)與版本的Android工作室科特林插件= '1.1.3-2' 3)ANKO庫
我有什麼問題面對應用程序運行時: 1)setError()方法沒有被調用。 2.)我無法在editText上使用setText()和setFocus()。
請注意,我需要Kotlin解決方案而不是Java。
在此先感謝!
private fun askAppointment() {
if (editTextPersonName?.text.isNullOrEmpty()) {
editTextPersonName?.error ="Person Name cannot be empty."
return
} else if (editTextPersonMobile?.text.isNullOrEmpty()) {
editTextPersonMobile?.error = "Person Mobile cannot be empty."
return
} else if (editTextPersonEmail?.text.isNullOrEmpty()) {
editTextPersonEmail?.error = "Person Email cannot be empty."
return
} else if (editTextSubject?.text.isNullOrEmpty()) {
editTextSubject?.error = "Subject cannot be empty."
return
} else if (editTextDescription?.text.isNullOrEmpty()) {
editTextDescription?.error = "Description cannot be empty."
return
} else if (editTextAppointmentDate?.text.isNullOrEmpty()) {
editTextAppointmentDate?.error = "Appointment Date cannot be empty."
return
} else if (editTextAppointmentTime?.text.isNullOrEmpty()) {
editTextAppointmentTime?.error = "Appointment Time cannot be empty."
return
}
請保持您的代碼小。目前尚不清楚您遇到問題的位置,只需添加包含問題的必要代碼即可。 – guenhter
@guenhter可以告訴我如何使用setText(),setText()在android中的editText與KOTLIN ... n也setError() –
不,我沒有進入android並不能給你的建議,但如果你做了一個更好的描述(https://stackoverflow.com/help/mcve最小,完整和可驗證的例子),任何人都可以幫助你,而不僅僅是降低你的問題。 – guenhter