【发布时间】:2020-01-30 12:27:28
【问题描述】:
我想要做的是从用户那里获取输入,然后在按钮单击事件中我想在 TextView 上显示 EditText 输入。在按钮单击侦听器上,textView 应该以全部大写形式显示输入字符串,然后单击同一个按钮,它应该将该字符串转换为小写并在TextView 上显示。我怎样才能做到这一点?
这是我尝试过的。
var userInput = findViewById<EditText>(R.id.editText)
var caseButton = findViewById<Button>(R.id.upperLowerButton)
var caseView = findViewById<TextView>(R.id.textUpperLower)
caseButton.setOnClickListener {
caseView.text = userInput.text
}
【问题讨论】:
-
caseView.text = userInput.text.toString().toUpperCase()/toLowerCase()
标签: android kotlin android-edittext