From the course: Building an Android App with Jetpack Libraries

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Display a selected note in the editor fragment

Display a selected note in the editor fragment - Android Tutorial

From the course: Building an Android App with Jetpack Libraries

Start my 1-month free trial

Display a selected note in the editor fragment

- [Instructor] Right now, when the user select a note in the list they're taken to the editor fragment, and that fragment displays the primary key of the note object. Now, I want to change this code. So when the user selects this item, I'm displaying the notes text in the editor, edit text box. To make this change, I'll start in the Editor Fragment, and from there go to the Editor ViewModel. As I dId with the other ViewModel class, the one for the main fragment, I'm going to change this from ViewModel to AndroId ViewModel. And that will let me get the context I need so that I can easily create my instance of the database. I'll change the superclass to AndroId ViewModel. I'll add a parameter for the Editor ViewModel class named app, and that's an instance of the AndroId application class. And then I'll pass that to the AndroId ViewModel superclass. Now, I'll get a reference to my database and this code will look exactly the…

Contents