Reputation: 87
Using a Kotlin code i want to know how to add a button outside the action bar which takes me to the previous Activity on click
Upvotes: 5
Views: 7776
Reputation: 465
You can call finish() when button is clicked
button.setOnClickListener {
finish()
}
Upvotes: 9
Reputation: 4269
Just call onBackPressed();
method from whereever you want to go back to the previous activity/screen. as follows :
btn.setOnClickListener(){
onBackPressed()
}
Upvotes: 6