override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main2)
val button2 = findViewById<Button>(R.id.button2)
val button3= findViewById<Button>(R.id.button3)
button2.setOnClickListener {
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
button3.setOnClickListener {
val intent = Intent(this, Main3Activity::class.java)
startActivity(intent)
}
}
button3.setOnClickListener {瓦尔意图=意图(此,主3活动::class.java)开始活动(意图)
未执行,请协助
1条答案
按热度按时间jgwigjjp1#
您似乎错过了关闭button2.setOnClickListener上的花括号},并将button3.setOnClickListener放入button 2单击侦听器中。只需关闭button 2单击侦听器中的startActivity(intent)后的括号,即可正常工作。