All Questions
Tagged with android-jetpack-compose android-viewmodel
235
questions
1
vote
2
answers
88
views
How to pass a String parameter to a viewmodel in compose?
How can I pass a String parameter to a ViewModel in Compose? I mean a string variable, not a hardcoded one or an Application stored one. I need to pass it as a parameter. This is just for learning ...
0
votes
0
answers
47
views
Jetpack Compose architecture with recursive screens using deep links and memory leaks
I have built an architecture based on Jetpack compose and I don't want to use Flows if possible. The data is in a tree structure; based on Requirements and Selections; which are rendered in a section-...
0
votes
0
answers
68
views
How to Display images you captured inside a horizontal pager in kotlin jetpack compose
I am trying to capture images inside a horizontal pager composable, Each time I take an image I want it to be displayed inside the horizontal pager. The application crashes every time I capture an ...
0
votes
1
answer
48
views
How to trigger recomposition when observing LiveData
I'm migrating an app from views to compose and am trying to trigger a schedule update every five minutes in which if there is a change in the data compose should recompose. Still using RxJava in my ...
0
votes
1
answer
352
views
Have the remember constructs in Android jetpack compose to be used only in the context of a composable function?
My question is about the remember constructs used in jetpack compose and kotlin. As you most probably already know these are the ones I am reffering to:
var first = remember { mutableStateOf(true) }
...
2
votes
1
answer
78
views
viewModels not found in jetpack compose
I am trying to use a delegate function with viewModels, but I'm encountering an issue when trying to import it.
@Composable
fun ImagePickerScreen() {
val viewModel : ImageViewModel by viewModels
}
...
1
vote
2
answers
69
views
Jetpack Compose: 'by viewModels()' vs 'viewModel<ViewModelName>()'
What's the difference here?
val myViewModel: MyViewModel by viewModels()
versus
val myViewModel = viewModel<MyViewModel>()
How does the first way work? How does it know which ViewModel to ...
0
votes
1
answer
104
views
How to retrieve entries when selecting dates when clicking on different dates through CalendarView
I'm trying to query entries (1 or more) from clicking my CalendarView on the screen, but I got stuck in trying to figure out how to continue on in order to display these entries as I'm new. I didn't ...
0
votes
1
answer
48
views
Sharing viewmodel between Android Composabe functions
Are there any problems that arise when sharing the same viewModel between composable functions?
3
votes
2
answers
504
views
Android Jetpack Compose: ViewModel state resetting on tab switch
I'm developing an Android app where I have a bottom bar. I am using Jetpack Compose, hilt and ViewModel. I have a ViewModel (ShopListHomeViewModel) that manages the state of a screen (...
0
votes
1
answer
42
views
Avoid the same function being triggered repeatedly in the ViewModel when a Jetpack Compose view recomposes during view loading in Android
I'm building an Android app using Jetpack Compose. I have a view that displays user details and uses a ViewModel to manage the data. The user details are fetched from a service or database. However, ...
0
votes
0
answers
22
views
CreationExtrasViewModel sample location
When using ViewModel, more exactly the following:
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0'
Functions viewModel are reffering the following sample in the docs:
/**
* ...
...
1
vote
2
answers
85
views
How to sync ViewModel State with (room) db?
I have been reading most android doc and more, but I can't find info about this topic.
I know how to create and edit a state inside my viewModel, as described in many android code labs. But I'm not ...
0
votes
1
answer
935
views
Collecting Flows in the ViewModel
I'm writing an Android app with Compose and a Room database. I've got a working solution, but I'm unsure if I'm using best practices. I'm collecting two flows in my ViewModel's init so I can create ...
0
votes
1
answer
328
views
Inject a class into a composable function using hilt
I figured out I don't really need my viewmodels to be lifecycle aware and I want to replace them with just plane kotlin classes to handle the ui logic, my problem is hilt; since it will only allow me ...