Issue
I am building my first App. My question is:
How can i put the Intent into "liste2" when "liste1" is not empty?
My Code:
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")
}
}
}
The Intent of the other Activity:
private fun favoritesButtonSaveText(){
favorisieren.setOnClickListener{
val save = Intent(this, favorites::class.java)
save.putExtra("key", sourceTextField.text.toString())
startActivity(save)
}
}
Thank you for your help and time!
Solution
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")
}
}
}
Answered By - Muhammad Ahmed
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.