In this video, learn how to switch from using a XML layout to an AnkoComponent. See how to update the createView method of a Fragment, as well as how to expose the AnkoComponent's views.
- [Instructor] Once you havr your Anko component created,…you can start to use it in your Android views.…Let's move over to our fragment and wire it up…to use your component over its XML layout.…So the first thing we want to do…is create an instance of our planet detail UI component.…Now since we're not going to be using the XML layout anymore,…we can actually remove the lines from 22 to 25…because we're not going to be setting the text views…by means of the find view by ID call.…
So instead, we're going to replace it with a private val,…and let's call our component UI,…and we're going to create it lazily,…so that we only create it the first that it's accessed,…and then we'll just provide…a call to our constructor, PlanetDetailUi.…Okay, perfect.…So next, we can go ahead and update the onCreateView method.…So everything from line 31 all the way down to 38…is no longer needed.…
So we can simply delete all of this.…And for our return value,…we're now going to use the view…that's generated from our Anko component.…
- What Kotlin has to offer
- Working with lambdas
- Common Android extension functions
- Kotlin Android Extensions overview
- Making use of the Anko library
- Working with coroutines
- Nullability and collections
Skill Level Intermediate
Android App Development: Data Persistence Librarieswith Annyce Davis3h 59m Intermediate
Developing AWS Lambda Functions with Kotlinwith Troy Miles1h 55m Intermediate
1. Kotlin Overview
2. Extension Functions and Properties
3. Incorporating Anko
4. Advanced Anko
5. Working with Collections
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.