viewmodel Questions
2
Solved
After updating navigation component and lifecycle viewmodel version to 2.5.0-alpha01 I have got following issue.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.atcc.aewp/co...
Cacilie asked 31/1, 2022 at 18:42
3
I have a fragment which basically only holds a bottomnavigation and a viewmodel. This viewmodel is shared by all the childfragments in this fragment. My parentfragment looks a bit like this:
class...
Pesek asked 28/11, 2019 at 17:58
2
Solved
private val _users = MutableLiveData<List<User>>()
val users: LiveData<List<User>> get() = _users
fun getUsers() {
viewModelScope.launch {
_users.value = users()
}
}
su...
Consubstantial asked 7/4, 2021 at 12:0
1
I am using databinding together with the TextInputLayout/TextInputEditText combo as shown in the xml.
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/lastname_input_lay...
Andrea asked 27/4, 2020 at 19:31
4
I have a single Activity application. In one part of the app there is a master-detail combination of Fragments that use a shared ViewModel to share some data between them. The problem I face is tha...
Beccafico asked 21/2, 2019 at 7:32
2
I have been trying to implement the LiveData and View Model. In this App, a number is displayed on the screen and we can add five or minus one. Now Earlier I used viewModelProvider but now it is de...
2
Solved
I recently started with the ViewModel and AndroidViewModel, I see there are different approach to initialise a viewModel instance, for me all works fine, I just want to know which one to use when? ...
2
I am using jetpack-compose in my project, and don't know how to change a TextField's value from my ViewModel.
In my Activity:
...
@Composable
fun myView() {
var dName = remember {
mutableStateOf(...
Bob asked 22/12, 2021 at 9:28
1
Solved
I want to deport my @FocusState into my viewModel:
struct ContentView: View {
@ObservedObject private var viewModel = ViewModel()
var body: some View {
Form {
TextField("Text", text...
1
Solved
How would the @Composable ContentFeed() function access the viewModel which was created in the Activity? Dependency injection? Or is that a wrong way of doing things here? The viewModel should alwa...
Wester asked 13/12, 2021 at 12:32
2
MVVM architecture,
this is my View (Activity):
private MyApp app;
private MainActivityVM viewModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceSta...
Robins asked 23/1, 2018 at 9:53
6
Solved
I have a window made up of several user controls and was wondering whether each user control have its own view model or should the window as a whole have only one view model?
Liberec asked 21/12, 2009 at 10:29
1
Solved
My viewmodel module looks like this:
val viewModelModule = module {
viewModel { (id: Int, user: String, email: String) ->
MyViewModel(get(), get(), id = id, user = user, email = email)
}
}
s...
10
Solved
I am new to the mvvm pattern. I created a ViewModel for the main activity. Now I want to get an instance of the ViewModel in the main activity.
Most Tutorials and answers here on Stackoverflow su...
Shaddock asked 28/1, 2020 at 16:3
3
I have a view model.
I am using Hilt.
I can create this view model from activity, like this
val model: ProfileViewModel by viewModels()
However when I try to create this view model from a composab...
Bema asked 22/4, 2021 at 7:4
1
I want to provide some dependency at run time to ViewModel using Hilt. I have followed the solution that was directed by d.android.com this.
@HiltViewModel
public class ViewViewModel extends ViewM...
Diverting asked 4/8, 2021 at 10:15
2
Solved
I am trying to use the same instance of ViewModel in Parent Fragment and its children, using Navigation Component. The hierarchy is as follows: Single Activity that has navigationHost. This host ha...
Jesse asked 22/2, 2020 at 20:30
1
Solved
I have a parent Fragment that has inside a FragementContainerView in which there is a transition of different Fragments. The parentFragment has a button that when is clicked it has to collect all t...
Convertible asked 5/7, 2021 at 11:8
4
Solved
I put a ListView in the middle row of a View. The view is contained in a window that has SizeToContent set to WidthAndHeight. The ListView is initially empty, but the underlying ViewModel fills thi...
6
I use DialogFragment (onCreateDialog) and ViewModel for it. But, when I try to pass getViewLifecycleOwner() to the LiveData::observe method I get the error below:
java.lang.IllegalStateException: ...
Indoaryan asked 19/2, 2019 at 12:15
4
Solved
We have been discussing about this but we don't know the reason of creating a viewmodel factory to create a viewmodel instead of instantiate the viewmodel directly. What is the gain of creating a f...
1
Solved
I am implementing the MVVM in fragments using the bottom navigation with firebase. But it's not working in my case. I searched for many solutions but didn't solve my problem.
I implemented viewMode...
Mhd asked 15/7, 2021 at 14:4
4
Solved
I am working on WPF MVVM application wherein I have 2 views View1 and View2 with their respective ViewModels. Now, I want on click of a button in View1 would close View1 and open View2 using ...
1
Solved
So I have a kotlin file named "ListScreen" (it's not a class! just a .kt file with composable functions) and I'm handling transactions with compose navigation graph system.
Right now I'm ...
Khorma asked 1/7, 2021 at 14:34
4
Solved
I try understanding ViewModel. I create ViewModel:
public class UsersViewModel extends ViewModel {
private final UsersRepository usersRepository;
public UsersViewModel(UsersRepository usersRep...
© 2022 - 2024 — McMap. All rights reserved.