Step #2: Renaming Our Layout

We want to show the layout resource that we tweaked in the preceding chapter. However, our layout resource is called activity_main, and we want to use it from a fragment, not an activity.

So, let’s rename this layout to todo_roster instead.

To do that, right-click over res/layout/activity_main.xml in the project tree, then choose “Refactor” > “Rename” from the context menu. This will bring up a dialog for you to provide the replacement name:

Android Studio Rename Dialog
Android Studio Rename Dialog

Change that to be todo_roster.xml, then click “Refactor”. This may display a “Refactoring Preview” view towards the bottom of the IDE:

Android Studio Refactoring Preview view
Android Studio Refactoring Preview view

This will not appear for everything that you rename, but it will show up from time to time, particularly when Android Studio wants confirmation that you really want to rename all of these things. If it does show up, click the “Do Refactor” button towards the bottom of the “Refactoring Preview” view.


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.