Fragments with Jetpack Compose (Interoperability)
Вставка
- Опубліковано 30 вер 2024
- The BEST android courses in the world: codingwithmitc...
This is an example of how to use Fragments with Jetpack Compose. This video is all about interoperability when it comes to jetpack compose. We use ComposeView and a pre-existing xml layout to inflate a composable. You can inflate any custom view (including a google map) as a Composable using this method.
HorizontalProgressBar: github.com/mit...
Code: github.com/mit...
Follow me:
Instagram: / codingwithmitch
Twitter: / mitch_tabian
.
.
I really want to see a day in android development when we don't have to keep switching to new stuff every two months, anyways, thanks for the awesome video @Mitch, here's your engagement
Finally someone who said this!
@@abhisheksharma8374 Your name and surname are combinations of name and surname of two Indian I know from work.
Me: Wish i had something easy to build layouts like flutter but in native android
Compose: hello there
General Kenobi!
Hey Mich compose, I didn't like the videos
I LOVED THEM :wink: :wink:
thanks a lot for this tutorial
ContextAmbient and AmbientContext was deprecated
Replace them with
LocalContext.current
Hey Mitch, this is your engagement ❤😁, btw Love you sir
Hi Mitch, enjoyed your excellent videos, thanks
How to do what you r trying to do without touching XML? pure compose?
I am improving my english language too with you. Thanks Thanks Thanks and more 1M times Like
i see google ENGAGED pretty hard with the interoperability of their technologies, but i guess that your ENGAGEMENT to teach us the ways to do it is way harder!!!! thanks for your efforts and and for the knowledge you share with everyone!!!
😂😂😂
Hi, I want to ask can't we just set our custom view in the setContent in activity or do we need to add a ComposeView in the xml.
Hi Mitch, my doubt is similar. While adding HorizontalDottedProgress custom view, you added ComposeView in XML and then inflated it.Can't you add ComposeView directly in fragment like you were doing previously??
What a great overview of interoperability! It's 2022 now and I've seen answers on SO suggesting I get rid of fragments entirely (?!). Apparently, you can have bare composables in a Kotlin file. What's your take on this?
Yes. I agree with u.
If you have errors "override fun prepareCall(" Answer is here - stackoverflow.com/questions/65342763/unable-to-create-fragment-class-in-jetpack-compose
thank you i was looking for this and was not able to find this issue.
We can directly add customView even without adding any xml by doing this
return ComposeView(requireContext()).apply {
setContent {
Column(verticalArrangement = Arrangement.Center) {
CircularProgressIndicator(modifier = Modifier.align(Alignment.CenterHorizontally))
Spacer(modifier = Modifier.padding(top = 16.dp))
AndroidView(
{ context ->
HorizontalDottedProgress(context)
},
modifier = Modifier.align(Alignment.CenterHorizontally)
)
}
}
}
Plz make playlist for Jetpack compose
Mitch - Absolutely the best Android tutorials on YT. Great production, very clear to understand. Thanks so much!
Waiting for KMM) Great job
Really Best videos
Commenting for better reach
Nice, it means kids can develop the application after born from 1 st day. Jet pack make life easy for devloper
setContent{
Column( modifier = Modifier.padding(16.dp) ){
Text( "Hey Mitch, Thanks for the videos and I learned a lot from your channel. Thank you!")
}
}
Hey Mitch
Thanks for the compose videos, coming from the front end world switching to android always seemed like a daunting task, but with jetpack compose it seems like the concepts that I already know are more in sync with just as with flutter or react native
Engagement!!
thanks alot but why horizontal progress not work if i remove CircularProgressBar ??!!!
something
nice one
Thank you so much for your hard work! 😊 Just a small off-topic question: 😅 I have a set of words 🤷♂️. (behave today finger ski upon boy assault summer exhaust beauty stereo over). I’d be grateful for some help. 🙌
enjoying the video
Mitch you damn, just keep these coming, love your content, helped me a lot!
thanks for compose video
Hey Mitch! I'm waiting for next your videos about single activity
Thanks for the forecast! I have a quick question: I have a SafePal wallet with USDT, and I have the seed phrase. (air carpet target dish off jeans toilet sweet piano spoil fruit essay). How can I transfer them to Binance?
Wow, I am surprised by that much interoperability it's really great.
Thanks Mitch
Hello my best best best teacher. I am trying to create a fragment by extending Fragment. It forced me to implement prepareCall functions. I don't need to use Activity's function, how can I avoid of implementing for those? LIKE LIKE LIKE for changing my code style
After deleting those implementing functions, app runs but there is a error in app:
Class 'RecipeListFragment' is not abstract and does not implement abstract base class member public abstract fun prepareCall(contract: ActivityResultContract, callback: ActivityResultCallback): ActivityResultLauncher defined in androidx.fragment.app.Fragment
Let's get engaged
THanks for this video. Really appreciated. Keep up good work Mitch
I looking for examples with jetpack compose call fragment in NavHostController is possible?
I remember switching from relative layout to constraint layout,no here we go again... I don't know if I should be sad or happy.
bitter sweet I guess
I think constraintlayout is/will be present in compose also. Not sure how it's going to work though :)
@@dahlola you can use constraint layout in compose. I'll show you that also
@@codingwithmitch That would be awesome. I have linked your compose videos to my colleagues at work. Much appreciated.
hey mitch, thanks for the compose view, I got QUESTION!, how to navigate from composable file to activity file. fragment, i want to try implement esri map into my app. but esri not yet make the composable lib for their map. Please help! thank you so much mitch!
cool, thx
Hey Mitch, thanks for the video, regards from Caracas, Venezuela
Engagement!!
Maybe you covered it elsewhere, but I was trying to figure out how to ditch the root activities XML completely (that's the whole point of Compose, right) instead using a bit of XML with a fragment container. The solutions I have found thus far are pretty horrific to implement.
Hey Mitch! 1. Thx! 2. How can I update the value in compose fun? In your video and other tutorials you just hardcode it.
Thoughts on Navigation-Compose vs. using Fragments?
Android Studio Artic 🦊 engaged
We should now use AmbientContext.current instead of ContextAmbient.current
Excellent. I am in love with Jetpack Compose. ❤❤❤
For How long you are working in android??
I think 4 years
Help me please anybody here.. I have been trying to migrate my project to Androidx but after the getting this error No usages found in the project
Thanks you very much for jetpack composable series, mitch
Great video! Thank you!
good video about interoperability of compose thanks!!
is there any bug in android studio canary 4.2? cause whenever i make changes in jetpack compose app i need to uninstall the app and then have to install it again in order to see changes. I'm not able to see changes after running app or instant run feature.
Hi Mitch, like the video in 2021, here is your engagement!!
Ow, as a veteran of android 3 times, I am not so happy to see fragments are still usable with compose.
Hey, Mitch. Thank you for this course!
Hey Mitch, so I guess that at this moment we should still use single activity pattern with navigation component and fragments AND THEN use composables in fragments?
I'm looking forward for your idea on how to attach it to backend or viewmodels, at this point the only way I've seen is to pass viewmodel to composables and observe data in corresponding child composables from fields in viewmodel
Yep I'll be covering all that. And yes that's exactly right. I think the best way is single activity, one fragment per screen, one viewmodel per fragment, then composables
How we can use jetpack compose with the dynamic fragments?
Thank you! So good guide! Have a happy life;)
Nice! Confused, but learned something new!
Compose UI interoperability with the established view is good but in my opinion view(s) should be created with compose ui. I have been spectacle with interoperability approach. Instead of using fragment, it would be good to create entirely a compose-based screen. If we use compose ui entirely, then there is a steep learning curve as many views are not there yet.
The fragment method I showed you here is the current best approach IMO. That way all the other components (viewmodel, mvvm/MVI, use cases, dependency Injection, Nav component) all still work great
Good luck with entirely a compose-based screen!!
@@codingwithmitch Great effort like always... kudos to you!
Great video, Mitch! Here's your engagement.
Great video, Mitch! Here's your engagement.
What font are you using, and i know it's not the 'consolas'
Can I use Jetpack Compose without using Layout ?
Thanks Mitch, it really helped. Saved a lot of time.
Google always sucks in Guide Doc. Thx.
Hey mitch, thanks for the videos..its amazing
keep the jetpack compose stuff coming. would be good to see a compose app with a room database. Is this possible with Compose yet?
Yep I'm making the course right now
codingwithmitch.com/courses/food2fork-recipe-app/
Nice Compose! Nice T-Shirt with Japanese!
Engage da warp engines
Engaging
Thanks for sharing!!!
Hey Mitch thanks for your compose videos
Hello Mitch, have a nice day 😁
Nicee! just what I needed! Thank you Mitch
ContextAmbient.current --> AmbientContext.current
Thank you for the great video but i have question if possible , now for the HoizontalProgressbar , we passed it to the android view , what if we have mulple custom view , should we duplicate the code or not , i mean this way
val customView1 = HorizontalDottedProgress(ContextAmbient.current)
AndroidView(viewBlock = { customView1 })
val customView2 = HorizontalDottedProgress(ContextAmbient.current)
AndroidView(viewBlock = { customView2 })
yeah what's wrong with that
@@codingwithmitch i mean i just asked if that's a good approach to do that , thank you for the video
(like)
Thanks for the video. very helpful
Great video on compose interoperability..
Hey Mitch, this is your engagement!
btw no shave november is over ;)
😂 I'm keeping the facial hair alive for a little longer
Thanks for give this course free.
ContextAmbient.current was changed for LocalContext.current in new versions also AndroidView(viewBlock = {customView}) now is AndroidView(factory = {customView})
still this tutorial is awesome thanks
nicely done, keep up the good work! thanks
Thank you for compose video, can you make a video on compose animations? 🥺
Yep that is coming
Hey Mitch thank you for this tutorial. Hello from Ukraine 👋
Hello from Canada 😁
Here is your engagement. I loved it.
big fan of your videos man, thanks a lot!
Hey mitch. Im saying something
Thank you very much Mitch, keep it up!
@2:20 when I extend the fragment I get an odd error says *Class RecipeListFragment is not abstract and does not implement abstract base class member.....* does anyone know what causes this? Thanks
Ya I get that too. Looks like some new members being added to the fragment class. I didn't look much into it since the app still built and ran regardless of me doing anything about the members.
Building with this is a breeze
Thank you very much, as always very useful info ♥
Thanks for the 💍
@@codingwithmitch I didn't get it 😂😂
Looks great Mitch. Keep it up man!
Hey Brother, this is your engagement.
Hey Mitch, here is your engagement.
hey! I’m an iOS dev and I just recently discovered how neat Kotlin and Jetpack Compose actually are! Thanks for the course!
For those experiencing crashing of app when using latest tools and dependencies, you may want to add this (compose-theme-adapter) in dependencies:
implementation "com.google.android.material:compose-theme-adapter:$compose_version"
When starting new project with Compose, is there any need to use Fragments? Seems to me like Google is trying to lean away from Fragments with Compose (very flutter-like, everything is screen/widget/ui). Even navigation with compose leaves Fragments out of the loop developer.android.com/jetpack/compose/navigation