当在ViewModel和LiveDate中使用时,为了使用带有参数的查询,我没有找到任何解决方案,所以我尝试为视图模型类和存储库类创建另一个构造函数,但我注意到在CodeLab 中,它们根本不使用视图模型构造函数,而是使用视图模型提供程序,所以我对其进行了更改和使用而不是
new ViewModelProvider现在它运行得很好,但是
我用DataBinding设置了我的项目,因此单击RecyclerView项,片段的ViewModel获取数据,并需要更改片段。因此,我创建了一个回调,该回调在片段本身中被嵌入以更改它,但是当它被调用时,getActivity()函数(或“activity”?)如下面所写)是空的。{ // Here is the issue <--------------------
com.example.android.guessit.GameFlow.FragmentAnswer1.onCreateView(FragmentAnswer1.java:125) at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java)
myapp.com.myapp.Controllers.Fragments.Parents.MyParentFragment.getCoordinator fun newInstanceMyObject, anotherObject: AnotherObject, coordinator: FragmentCoordinator): MyFragment { fra
当试图在viewmodel类中引用片段时,我遇到了一些问题。java.lang.ClassCastException: com.mainapp.App cannot be cast to android.app.Activity
at com.mainapp.viewmodel.SummaryViewModel.export