viewmodel Questions

2

*EDIT: To answer my own question, I had to add EditorViewModel as an import to the parent abstract class in the outer layout, and cast the viewModel to the parent class using app:viewModel="@{((Edi...

3

Solved

Is there a way to have a data annotation for what should be in placeholder attr on a textbox in an MVC view? Example: In my ViewModel.cs, something like: [Placeholder="First name"] public string...
Rheumatism asked 31/1, 2012 at 19:52

3

Solved

We can initialize the ViewModel class using private val viewModel: CharactersViewModel by viewModels() or viewModel = ViewModelProvider(this).get(CharactersViewModel::class.java) Herer Characters...
Photoactive asked 18/12, 2020 at 5:47

9

Solved

So I'm using the new navigation component (with the one activity principle) and communicating between each fragment using shared view models, however, I've come to a point where I sometimes need to...
Williemaewillies asked 17/12, 2018 at 14:14

4

How can I change in ViewModel source of my LiveData from Room Dao. In WordDao I have two queries: @Dao public interface WordDao { @Query("SELECT * FROM " + Word.TABLE_NAME + " ORDER BY text ASC"...

2

Solved

Can you tell me if my approach is right? It works but I don't know if it's correct architecture. I read somewhere that we should avoid calling viewmodel function on function responsible for creatin...
Brunabrunch asked 17/2, 2021 at 9:13

1

there are fragments in viewPager and each fragment has a viewModel. when viewpager's current item changes ,fragment is destroyed ,viewModel onCleared is called and viewModelScope is cancelled there...
Lenhart asked 17/2, 2021 at 11:35

6

Solved

I just want to get a reference in my Fragment (extends Fragment) to my ViewModel.class (extends from AndroidViewModel). This is how it is described everywhere: UserModel userModel = ViewModelProvi...
Blazonry asked 10/7, 2018 at 12:7

2

I'm having the following ViewModel: public class FeedViewModel extends ViewModel { private final FeedRepository repository; private LiveData<Resource<List<Photo>>> feed; @Inject...

1

I'm currently working on a big project where I have a ViewModelA using MediatorLiveData to observe other LiveData sources. I would like to have this ViewModelA observing data from a ViewModelB. One...
Oloroso asked 13/1, 2021 at 14:53

9

Solved

I'm using NHibernate to persist my domain objects. To keep things simple I'm using an ASP.NET MVC project as both my presentation layer, and my service layer. I want to return my domain objects in...
Dudeen asked 30/12, 2009 at 19:42

1

Solved

I am trying to access the same shared model within two different view models. Both associated views need to access the model within the view model and need to edit the model. So I can't just use th...
Hinkley asked 30/12, 2020 at 9:55

0

I know that is not a best practice to pass a context to a ViewModel. but I wonder is it okay to get a context instance as a local parameter of a function in the ViewModel? because in this case the ...
Haemostatic asked 28/12, 2020 at 9:27

2

Solved

In the summer of last year I started refactoring my Android application with Android's architecture components (Room, ViewModel, LiveData). I have two Room repositories, one of them is accessed by...
Krall asked 28/2, 2020 at 12:10

6

In my current project I use the next line: mViewModel = ViewModelProviders.of(this).get(MainViewModel::class.java) For instance a ViewModel but in https://developer.android.com/reference/android...
Delitescence asked 2/2, 2019 at 4:17

4

Solved

This might be a stupid question! (n00b to AutoMapper and time-short!) I want to use AutoMapper to map from EF4 entities to ViewModel classes. 1) If I call CreateMap<ModelClass, ViewModelClass...
Triarchy asked 31/5, 2011 at 8:44

0

I'm trying to implement an editing cart in my project. For that, I have used a spinner. I posted two methods: one using ViewModel and one without. When I am not using ViewModel, it works fine. The ...
Alage asked 26/10, 2020 at 13:1

5

Solved

Getting error while running app which have dependencies 'androidx.lifecycle:lifecycle-extensions:2.1.0-alpha03' and 'androidx.lifecycle:lifecycle-viewmodel:2.1.0-alpha03' on device with Android 4.4...
Hag asked 15/3, 2019 at 7:13

2

Solved

my login is not working ..im using retrofit and viewmodel ...actually scenerio is onclick of login shows the transition(loginpage to loginpage) but it is not moving to loginpage to homepage.... thi...
Cowpox asked 19/10, 2020 at 6:7

3

Solved

im trying to do login using retrofit and viewmodel i have done successfully login with only retrofit...referred this tutorial--> https://www.youtube.com/watch?v=j0wH0m_xYLs i havent found any tu...
Quality asked 14/10, 2020 at 11:58

1

Solved

my data is fetched only when it is created...im using viewmodel...when press back button it doesnt update the previous data..onresume is not working in this... i refered this but none of those help...
Pahari asked 15/10, 2020 at 12:43

1

Solved

basically im trying display list in recyclerview using retrofit and viewmodel........ on debugging the onresponse im getting 200 response but why is it not displaying list in recyclerview i dont kn...
Lacking asked 15/10, 2020 at 5:48

2

I have an AddressesViewModel which holds the user's favorite addresses and another SearchViewModel which holds searched addresses. when user searched an address I have to check whether this address...
Reality asked 7/1, 2019 at 8:1

5

I have recently seen a weird issue that is acting as a barrier to my project. Multiple calls to set the live data value does not invoke the observer in the view. It seems that only the last value ...
Christopherchristopherso asked 29/5, 2018 at 10:58

2

Solved

I am using a viewModel to pull livedata from a room data base. I have 2 LiveData that I pull from my viewModel and then I will run a function to pull data from my server. I need both values to be s...
Lurette asked 21/8, 2020 at 19:5

© 2022 - 2024 — McMap. All rights reserved.