Page switching transfer data
ViewPager+TabLayout page switching transfers data
, similar to receiving membership on the homepage. My page displays member time.
1、 application
val tag = MutableLiveData<Int>()
2. Write notifications where the data changes and deliver them when the data changes.
//初始化变量
val atomicInt = AtomicInteger()
(activity?.application as AccelerateApp).tag.postValue(atomicInt.incrementAndGet())
3. Refresh the UI for pages that need to be updated.
(activity?.application as AccelerateApp).tag.observe(viewLifecycleOwner) {
// 重新获取数据更新ui
//数据源也要放进去进行改变
}