Jetpack | Light and bright functional reactive framework | Reactive Programming library
kandi X-RAY | Jetpack Summary
kandi X-RAY | Jetpack Summary
Light and bright functional reactive framework
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Jetpack
Jetpack Key Features
Jetpack Examples and Code Snippets
Community Discussions
Trending Discussions on Jetpack
QUESTION
how can we pass parameter to viewModel in jetpack compose?
this is my composable
...ANSWER
Answered 2021-Jun-15 at 08:00you need to create a factory to pass dynamic parameter to ViewModel like this:
QUESTION
I want the size of the text to be in .dp
so that it doesn't change according to the system font.
How to achieve this in Jetpack Compose "Text" composable
ANSWER
Answered 2021-Jun-14 at 02:46Using em
made my font size consistent, irrespective of the system font size
Eg.Text("ABCD", fontSize = 10.em)
The question was also asked in google's issuetracker https://issuetracker.google.com/190644747
QUESTION
setContent {
AndroidView(modifier = Modifier) {
SurfaceView(it).apply {
holder.addCallback(this@MainActivity)
}
}
Column {
Button(onClick = {}) {
Text(text = "Button")
}
...
}
}
...ANSWER
Answered 2021-Jun-14 at 19:55If anyone stumbles over this question:
This is a known bug in the current Jetpack Compose build (1.0.0-beta08) which is supposed to be fixed with the next version.
As a workaround I was able to do it the other way round, creating the SurfaceView as well as a ComposableView in XML and adding my content to the ComposableView.
QUESTION
In Jetpack compose, we have the option of using rememberCoroutineScope()
as well as using the LaunchedEffect
composable in order to use coroutines / run suspend functions (show snackbars etc).
The convention I've adopted so far is to remember a single coroutine scope at the top of my compose tree, and pass it down via function arguments to places where it is needed. This vaguely seems like a good practice, but on the other hand it's adding extra noise to my function signatures.
Questions- Are there any reasons for preferring the use of
LaunchedEffect
overrememberCoroutineScope()
inside composable functions? - Is it worth the effort to only create / remember a coroutine scope once per compose tree, or should I just call
rememberCoroutineScope()
in each function where a coroutine is actually launched?
ANSWER
Answered 2021-Jun-12 at 23:42Leaving my understanding here:
Question 1:
LaunchedEffect
should be used when you want that some action must be taken when your composable is first launched. For example, when you want to request some data from your ViewModel or run some sort of animation...
rememberCoroutineScope
on the other hand, is specific to store the Coroutine scope allowing the code to launch some suspend
function...
imho, the only relation between them is that you can also use a LaunchedEffect
to launch a coroutine...
Question 2: As you can see in the docs, rememberCoroutineScope
will keep the reference of the coroutine's scope in a specific point of the composition. Therefore, if a given composable is removed from the recomposition, that coroutine will be cancelled automatically. For instance, you have the following composable calls A -> B -> C
. If you remember the coroutine scope in C
and it is removed from the composition, the coroutine is automatically cancelled. But if you remember from A
, pass the scope through B
and C
, use this scope in C
, and then C
is removed, the coroutine will continue running (because it was remembered in A
)...
QUESTION
how to use jetpack compose in android tv? The graphics are displayed normally, but the remote control cannot be used.
...ANSWER
Answered 2021-Jun-12 at 17:55Add a Modifier.focusable()
– that should do the trick.
QUESTION
I'm currently playing around with the new Jetpack compose UI toolkit and I like it a lot. One thing I could not figure out is how to use stickyHeaders
in a LazyColumn
which is populated by the paging library. The non-paging example from the documentation is:
ANSWER
Answered 2021-May-26 at 11:49I got it work by looking into the source code of the items
function: You must not call stickyHeader
within the items
function. No need to modify the PagingData flow at all. Just use peek to get the next item without trigering a reload and then layout it:
QUESTION
I'm doing the same as shown in the documentation here. I want to Inject the ViewModel into a Composable function (Screen), but I get this error:
Cannot create an instance of class com.example.blotube.ui.later.LaterViewModel
My ViewModel:
...ANSWER
Answered 2021-Apr-20 at 16:10This appears to be a bug in Jetpack Compose, will probably need to wait for an update on the Jetpack libraries to address it.
As a possible workaround, you could instantiate the viewmodel in your activity and pass it to your composable function
QUESTION
my first project using Jetpack Compose got an error like this, how can I fix it
Unable to find method ''void com.android.build.api.extension.AndroidComponentsExtension$DefaultImpls.androidTest$default(com.android.build.api.extension.AndroidComponentsExtension, com.android.build.api.extension.VariantSelector, kotlin.jvm.functions.Function1, int, java.lang.Object)'' 'void com.android.build.api.extension.AndroidComponentsExtension$DefaultImpls.androidTest$default(com.android.build.api.extension.AndroidComponentsExtension, com.android.build.api.extension.VariantSelector, kotlin.jvm.functions.Function1, int, java.lang.Object)' Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
My dependencies:
...ANSWER
Answered 2021-Jun-08 at 16:07Maybe your version is not compatible with gradle:7.0.0-beta03
, you should change it to gradle:7.0.0-beta02
in your dependencies
QUESTION
I was referencing the JetPack Navigation Component related documentation to create a bottom navigation for screen transitions.
But in that link it says:
- The recommended way to navigate between destinations is to use the Safe Args Gradle plugin.
- Safe Args is recommended both for navigating as well as passing data between destinations.
After seeing this, I have a few questions.
Is there a performance difference between just using the navaigation component
and using safe args
?
Of course, safe args
even has the ability to pass data between screens. But apart from this, is there any difference only in terms of screen transitions (navigation)?
ANSWER
Answered 2021-Jun-11 at 19:16Safe Args just generates code that you can write yourself, following the guide to navigating by ID and manually passing a Bundle
of arguments - it has no effect on the performance of your app at runtime or how screen transitions work.
QUESTION
I am getting this error when I build the project
...ANSWER
Answered 2021-May-20 at 10:26Update all compose libraries to beta07
:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Jetpack
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page