Reputation: 45
when I search the recyclerview item with my app's search bar after I see the recyclerview item It should have gone back to recyclerview list when I press back button but app closes itself instead of that.
Here is my codes ;
//SEARCH
searchBtn.setOnClickListener {
url = ""
postArrayList = ArrayList()
postArrayList.clear()
val query = searchEt.text.toString().trim()
if(TextUtils.isEmpty(query)){
loadPosts()
} else {
searchPosts(query)
}
}
What can I do for this ? Thank you
Upvotes: 1
Views: 77
Reputation: 19
You need to use onBackPressed button. Detail information is here: https://developer.android.com/guide/navigation/navigation-custom-back
Upvotes: 1