我正在使用android studio,但这段代码有些问题。有人可以告诉我我在做什么错吗? 系统不断告诉我“正在等待成员声明”。
这是代码
class MainActivity: AppCompatActivity() {
class TextView totalTextView; //This is where I am having the error
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setSupportActionBar(toolbar)
答案 0 :(得分:1)
我假设您正在尝试创建totalTextView变量。在kotlin中,您可以这样声明一个变量
lateinit var totalTextView : TotalTextView
答案 1 :(得分:0)
This is not right way to create or define object of TextView.
1 > var totalTextView : TextView ? = null
1 > lateint var totalTextView : TextView
In kotlin, No need to define id of ViewGroup items , avoid to define the instance of view item when you are using kotlin