Recyclerview - Notifydatasetchanged() - Kotlin - Not Working
I am having an issue with reloading data in RecyclerView after the data is updated with a separate URL call. The FristFragment calls LoadDataFromUrl and displays the data in the Re
Solution 1:
Create var myResponse: MyResponse
variable in Adapter
Adapter.kt
var recyclerView: RecyclerView? = nullclassMainAdapter(val myResponseInit: MyResponse): RecyclerView.Adapter<CustomViewHolder>(){
var myResponse: MyResponse
myResponse = myResponseInit
funsubmitMyResponse(data: MyResponse) {
myResponse = data
}
//Rest of the code onCreateViewHolder etc.
}
Call submitMyResponse()
function and notifyDataSetChanged()
on adapter everytime you receive response.
Post a Comment for "Recyclerview - Notifydatasetchanged() - Kotlin - Not Working"