由于不可预见的原因,ViewModelProviders.of( This ).get()失败了,这是在我的主活动(继承自FragmentActivity )中调用的。实际上,我在调用.get()时收到一个错误。该错误说明它期望的是一个activity,而不是一个与文档相冲突的ViewModel。我已经清除并使缓存失效了。AppCompatActivity() {
> create(modelClass: Class<T>): T { }视图
private val viewModel by lazy { ViewModelProviders.of(this, LoginVMFactory(PostUserTokenImpl(UserRepoImpl()))).<em
示例ViewModel: // Create a LiveData with a StringmCurrentName = new MutableLiveData<>(); return mCurrentName;主要活动:
mModel = ViewModelProviders.of(this).get(NameVi