October 2018
Intermediate to advanced
464 pages
15h 17m
English
To demonstrate handling the Fragment back stack, we'll create two fragments with a Next button to create a back stack. With that setup, we'll implement the onBackPressed() callback to exit the app when the user reaches the top Fragment. We'll be using the Fragment Manager from the support library, so be sure to choose the support library version when prompted for the import library. We'll need two layout files - one for each fragment - along with two fragment classes. Here are the steps in detail:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent" android ...