相关疑难解决方法(0)

Kotlin:如何使用Kotlin在Android中为TextView设置文本?

我是新手

我想更改文本,TextView点击它.

我的代码:

val text: TextView = findViewById(R.id.android_text) as TextView
    text.setOnClickListener {
        text.setText(getString(R.string.name))
    }
Run Code Online (Sandbox Code Playgroud)

输出:我得到了输出,但显示了使用属性访问语法.

谁能告诉我怎么做?

提前致谢.

android textview kotlin

20
推荐指数
5
解决办法
6万
查看次数

标签 统计

android ×1

kotlin ×1

textview ×1