Questions tagged [android-mvvm]

Questions regarding applying a Model-View-ViewModel in android application

773 questions
0
votes
1 answer

Getting ViewModel for SettingsActivity (MVVM, Android P)

If you choose template with Settings creating a project in Androdi Studio 3.4, you will see example app with SettingsActivity extending AppCompatPreferenceActivity extending PreferenceActivity extending ListActivity extending android.app.Activity,…
0
votes
1 answer

Login Example using Retrofit, MVVM, LiveData in android

I checked this article but observe the response changes in MainActivity. Here is my code for LoginRepo public MutableLiveData checkLogin(LoginRequestModel loginRequestModel) { final MutableLiveData data =…
Shubham Agrawal
  • 1,252
  • 12
  • 29
0
votes
1 answer

observing live data of view model in fragment

I am following the MVVM pattern in my android app. Here are the files that I will be talking about: PresentContestsFragment PresentContestsViewModel here's my code of view model: private val _contests =…
0
votes
1 answer

How to convert row JSON response into LiveData without using Room?

I am stuck at the conversion of JSON response into LiveData. This can be possible using Room. But I am not using Room in my app. private fun fetchFromNetwork(dbSource: LiveData) { //here 'result' is MediatorLiveData …
Kalu Khan Luhar
  • 1,044
  • 1
  • 22
  • 35
0
votes
2 answers

listen to changes in preferences in a simple fragment with view model

My app consists of a single activity. It has a navigation drawer which changes fragment in the activity. One of the nav drawer item is Settings screen which is androidx preference fragment and inherits PreferenceFragmentCompat. App uses MVVM…
0
votes
1 answer

android -MutableLiveData doesn't observe on new data

I'm using mvvm and android architecture component , i'm new in this architecture . in my application , I get some data from web service and show them in recycleView , it works fine . then I've a button for adding new data , when the user input the…
0
votes
1 answer

android - room database connection in Model class android architecture

i'm new in MVVM , i'm using android architecture components too . this is my code, I'e written the online part and now I'm working on offline part that needs to use the room database . this is my model class code : class CategoryModel( …
0
votes
1 answer

android- how to get list of properties from MutableList

This is my JSON : { "cats": [ { "id": "2", "uid": "2", "name": "English", "date_update": "2019-04-22 15:31:00", "numCards": 0 } ] } I've these two classes: data class CatModelStr( val cats:…
0
votes
0 answers

how to create progress/error view in dagger2 MVVM?

I'm using Dagger2, Retrofit & following MVVM pattern in an application. I want to show progress bar while the page is loading & error message for network error or any data related issues. in my current implementation without Dagger, I've created a…
akshay bhange
  • 2,320
  • 2
  • 28
  • 46
0
votes
1 answer

How to expand code/description to a complex object?

I want to present a list of the names/basic attributes of some complex objects (i.e. they are comprised of multiple collections of other objects) in a recycler view, then get the full object on user selection. For example, the top level objects are…
ZG862
  • 1
  • 5
0
votes
1 answer

I cannot set entries in sppiner with ViewModel, any idea?

I am trying set values in a spinner for this I have the following code: Strings.xml A B C D
Tlaloc-ES
  • 4,825
  • 7
  • 38
  • 84
0
votes
1 answer

Is it a bad practice to use a set inside get?

Hi I am using the MVVM pattern in an android project, and for the ViewModel have code like this: public class LoginViewModel extends ViewModel { public MutableLiveData user = new MutableLiveData<>(); public MutableLiveData
Tlaloc-ES
  • 4,825
  • 7
  • 38
  • 84
0
votes
1 answer

How can add viewmodel to layout when the layout is split in several files?

I have a layout splited in several files, this activity is an activity with drawer layout, then I have the next files: MapActivity.java @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); …
Tlaloc-ES
  • 4,825
  • 7
  • 38
  • 84
0
votes
1 answer

The nav header print @={loginViewModel.userId} instead of the data, why?

Hi I have an Activity with a drawer menu like the next: MapActivity.java Here setup the data binding like in other activities of the apps public class MapActivity extends BaseActivity{ private LoginViewModel loginViewModel; @Override …
Tlaloc-ES
  • 4,825
  • 7
  • 38
  • 84
0
votes
3 answers

No data from api in recycler view with retrofit and data binding

I'm trying to get the weather data from the web by Retrofit and I have problem with data display in recyclerview . In logcat is all data, so api and data downloading work, but recyclerview is still empty. EDIT: The problem is in the repository where…
user9897182
  • 255
  • 5
  • 18