我正在构建我的第一个应用程序。我的问题是:
我如何才能将意向放入";列表2";当";列表1";不是空的吗?
我的代码:
private fun insertTextToTv() {
val liste = findViewById<TextView>(R.id.liste)
val liste2 = findViewById<TextView>(R.id.liste2)
val liste3 = findViewById<TextView>(R.id.liste3)
if (liste.text.toString() == "") {
liste.text = intent.getStringExtra("key")
} else {
liste2.text = intent.getStringExtra("key")
}
}
}
其他活动的意图:
private fun favoritesButtonSaveText(){
favorisieren.setOnClickListener{
val save = Intent(this, favorites::class.java)
save.putExtra("key", sourceTextField.text.toString())
startActivity(save)
}
}
感谢您的帮助和时间!
private fun insertTextToTv() {
val liste = findViewById<TextView>(R.id.liste)
val liste2 = findViewById<TextView>(R.id.liste2)
val liste3 = findViewById<TextView>(R.id.liste3)
if (liste.text.isNotEmpty()) {
liste2.text = intent.getStringExtra("key")
}
}
}