I am generating tabs in a tablayout using ObservableField of list of objects and data binding. After a certain operation I have to update the tabs. When I trying to change the property of the list item, the UI is not updating. Below is my code.
val tabsList = ObservableField<List<TabModel>>(getTabsList())
// setting the data
tabsList.get()?.first { it.isSelected }?.setPrice(price)
I have also tried MutableLiveData, and it's also not working.
Any help is appreciated.
I find a solution for now. Maybe it's not the efficient way, but it is working in my scenario. Below is the code.
val updatedTabs = tabsList.get()
// setting the data
tabsList.get()?.first { it.isSelected }?.setPrice(price)
// setting a new list
tabsList.set(updatedTabs?.toList())