jetpack
文章平均质量分 77
m0_37588684
Android初级民工
展开
-
viewModel源码
基本使用:class ChooseAreaViewModel :ViewModel(){ var provinceLiveData = MutableLiveData<MutableList<Province>>() fun getProvinceList(){ viewModelScope.launch { provinceLiveData.value = PlaceRepository.getProvinceList()原创 2021-04-12 18:22:26 · 213 阅读 · 0 评论 -
viewModel在fragment中使用
viewModel在frgamnet中使用,如果使用activity例如viewModelFragment = ViewModelProviders.of(requireActivity()).get(ChooseAreaViewModel::class.java)这种方式和在activity中使用相同参考viewModel源码如果使用viewModelFragment = ViewModelProviders.of(this).get(ThirdFragmentViewModel::class.原创 2021-04-12 20:11:16 · 6588 阅读 · 0 评论 -
liveData使用和源码分析
liveData基本使用class ChooseAreaViewModel :ViewModel(){ var provinceLiveData = MutableLiveData<MutableList<Province>>() fun getProvinceList(){ viewModelScope.launch { provinceLiveData.value = PlaceRepository.getProvinceLis原创 2021-04-16 15:49:21 · 153 阅读 · 0 评论 -
lifeCycle使用及源码
lifeCycle使用class MyObserver:LifecycleObserver { @OnLifecycleEvent(Lifecycle.Event.ON_START) fun activityStart(){ Log.e("TAG","activityStart") } @OnLifecycleEvent(Lifecycle.Event.ON_STOP) fun activityStop(){ Log.e(原创 2021-04-15 18:14:20 · 116 阅读 · 0 评论