The dual-Fragment address book mini app
The app will show a list of names and allow the user to tap on a name so that it displays the address. What is new about this app is that when we compare it to the Note To Self app, it will behave differently depending upon whether it is in the portrait or landscape orientation.
When in the portrait orientation, tapping on a name will cause a new Activity
to open and display the address. When in the landscape mode, tapping on a name will cause the address to be shown on the right-hand side of the screen in the same Activity
. This next image clarifies this visually:
This is the kind of behavior a user might expect from a mobile app. The best part is that it doesn't matter whether the user is in the portrait or landscape orientation, the exact same Java code and XML layout will be used for both the list and the detail parts. We will, of course, achieve this feat by using Fragments.
Getting started
Create a new blank project called Dual Fragment
. This...