Skip to Content
Android 9 Development Cookbook - Third Edition
book

Android 9 Development Cookbook - Third Edition

by Rick Boyer
October 2018
Intermediate to advanced
464 pages
15h 17m
English
Packt Publishing
Content preview from Android 9 Development Cookbook - Third Edition

How to do it...

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:

  1. Create a new layout file called fragment_one.xml with the following XML:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_height="match_parent"    android ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Android Application Development Cookbook - Second Edition

Android Application Development Cookbook - Second Edition

Rick Boyer, Kyle Mew
Android High Performance Programming

Android High Performance Programming

Enrique López Mañas, Diego Grancini
Android Things Projects

Android Things Projects

Francesco Azzola

Publisher Resources

ISBN: 9781788991216Supplemental Content