Android 意图,相同 activity 正在重复
Android intent, Same activity is repeating
嗨,我第一次在 Kotlin 中编写 android 代码,当我尝试使用 Intent 而不是转到下一页时,相同的 activity 正在重复。我在这里给出我的activity代码
class MainActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// get reference to button
val btnStart = findViewById<Button>(R.id.start_button)
// set on-click listener
btnStart.setOnClickListener {
Toast.makeText(this@MainActivity, "You clicked me.", Toast.LENGTH_SHORT).show()
val intent = Intent(this, QuestionActivity::class.java).apply {
}
startActivity(intent)
}
}
}
val intent = Intent(this, QuestionActivity::class.java).apply {
}
startActivity(intent)
至
val intent = Intent(this, QuestionActivity::class.java)
startActivity(intent)
startActivity(Intent(这, QuestionActivity::class.java))
嗨,我第一次在 Kotlin 中编写 android 代码,当我尝试使用 Intent 而不是转到下一页时,相同的 activity 正在重复。我在这里给出我的activity代码
class MainActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// get reference to button
val btnStart = findViewById<Button>(R.id.start_button)
// set on-click listener
btnStart.setOnClickListener {
Toast.makeText(this@MainActivity, "You clicked me.", Toast.LENGTH_SHORT).show()
val intent = Intent(this, QuestionActivity::class.java).apply {
}
startActivity(intent)
}
}
}
val intent = Intent(this, QuestionActivity::class.java).apply {
}
startActivity(intent)
至
val intent = Intent(this, QuestionActivity::class.java)
startActivity(intent)
startActivity(Intent(这, QuestionActivity::class.java))