Category : viewmodel

Im trying to implement editting cart in my project..for that i have used spinner Adapter::——– var country = arrayOf(1, 2, 3, 4, 5, 6, 7, 8) . . . val aa: ArrayAdapter<*> = ArrayAdapter<Any?>(context, android.R.layout.simple_spinner_item, country) aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) holder.spin.setAdapter(aa) holder.spin.setSelection(dataList?.get(position)?.quantity!! – 1, false) holder.spin.setOnItemSelectedListener(object : OnItemSelectedListener { override fun onItemSelected( parent: AdapterView<*>, view: View, position1: Int, ..

Read more

HomeFragment.tk : class HomeFragment : Fragment() { private val questionViewModel: QuestionListViewModel by viewModels { InjectorUtils.provideQuestionListViewModelFactory(this) } var allQuestionsCount :LiveData<Int> = questionViewModel.getCountQuestions() … ELSE CODE } If i use questionViewModel for initializing other properties(like the above code), get the error: at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) Caused by: android.view.InflateException: Binary XML file line ..

Read more

I have a fragment called CharacterFragment which contains a viewpager with tablayout having 2 fragments. The Idea is to have a single viewmodel for the characterfragment and make the fragments from viewpager use it to get the data. I am using hilt for injecting the viewmodel. In the first section (about section) I am not ..

Read more

I am trying to fetch records from retrofit using NetworkBoundResource but not able to get a response. Actually when I did debug it did not go through all functions in Repository. Here my code for all classes NetWorkBoundResource abstract class NetworkBoundResource<ResponseObject, ViewStateType> { protected val result = MediatorLiveData<DataState<ViewStateType>>() init { result.value = DataState.loading(true) GlobalScope.launch(IO){ delay(TESTING_NETWORK_DELAY) ..

Read more

I am trying to inject the ViewModel into the adapter. It works fine while injecting into Fragment. ViewModel: class HomeViewModel @ViewModelInject constructor( ): ViewModel() Fragment: @AndroidEntryPoint class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>( R.layout.fragment_home ) { private val viewModel: HomeViewModel by viewModels() There is no problem so far. But problems arise when I try to inject into ..

Read more