引用ViewModel
Android引用ViewModel,lifecycle升级版本后,原方法失效
This commit is contained in:
parent
0576846d6c
commit
b80201e982
11
demo1/ViewModel.ky
Normal file
11
demo1/ViewModel.ky
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
class CrimeListFragment : Fragment() {
|
||||||
|
|
||||||
|
private lateinit var crimeRecyclerView: RecyclerView
|
||||||
|
private var adapter: CrimeAdapter? = null
|
||||||
|
|
||||||
|
private val crimeListViewModel: CrimeListViewModel by lazy {
|
||||||
|
//ViewModelProvider.of(this).get(CrimeListViewModel::class.java)
|
||||||
|
ViewModelProvider.AndroidViewModelFactory.getInstance(context?.applicationContext as Application).create(CrimeListViewModel::class.java)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user