[英]How to declare variables in Kotlin? I'm getting "Unresolved Reference"
You never "closed" lambda for the start_button
click listener.您永远不会为start_button
单击侦听器“关闭”lambda。 Add a closing curly brace }
:添加右花括号}
:
...
text_id.text = "my text"
} // <- this one's missing
you have to declare the variables and you should identify the view by id before using them as below.您必须声明变量,并且在使用它们之前应该通过 id 标识视图,如下所示。
TextView message_text;
Override fun onCreate(savedInstanceState: Bundle?){
Super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main);
message_text = (TextView) findViewById(R.id.message_text);
message_text.setText("abc");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.