From the course: Building an Android App with Jetpack Libraries

Unlock the full course today

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

Edit existing notes

Edit existing notes - Android Tutorial

From the course: Building an Android App with Jetpack Libraries

Start my 1-month free trial

Edit existing notes

- [Instructor] When the user views a note in the editor, they can make changes. When you close the editor fragment, you need to save those changes to persistent storage so that they then automatically show up in the list. To accomplish that, I'll start off in the editor fragment class. I already have a function called save and return, that's being called when I leave this fragment and I'll add some code to this function. First, I need to explicitly close that soft keyboard. Notice that when I click into this edit text box, and then I leave the fragment, the soft keyboard sticks around and I don't want that to happen. So I'll create a variable called imm that stands for input method manager, and I'll get that by calling requireActivity. And then from there, I'll call the following function, getSystemService, I'm passing a constant of Activity.INPUT_METHOD_SERVICE, and I'll cast the return value as an InputMethodManager.…

Contents