There are literally thousands of different distinct Android device models currently in use. They extend in size from small phones to tablets, and all the way up to less popular full screen implementations. Android apps have the ability to adapt to these different screen sizes, displaying different layouts by putting fragments together at runtime. There are a couple of ways to detect the screen's characteristics at runtime, including programmatic logic with Java, and automatic detection by the application framework based on resource directory names.
- [Voiceover] The most important purpose…of the Fragments API is to let you dynamically…adjust as an app is loaded on different devices…with different size screens.…I'm going to demonstrate, two different versions…of an application and run that application…on both a phone and a tablet, so you can see…the difference between using Fragments and not using them.…I'm going to work with versions of an application…that I've included in the exercise files…under Chapter One, 01_02.…There are two projects here,…HSportPhoneApp and HSportFragments.…
I'll open the phone version of the application first.…I'll open the MainActivity class,…and then from there, I'll go…to the associated XML layout files,…and I'll open activity_main.XML,…and from there, I'll go to content_main.…In this version of the application,…the listview component which displays…a list of data is a part of the main layout file.…It's not wrapped inside a fragment at all,…and similarly, the detail activity,…also doesn't use Fragments.…
I'll go to the DetailActivity Class,…
Author
Released
9/1/2016- Configuring Android Studio
- Understanding fragments
- Creating a fragment class and layout
- Adding and removing fragments with Java
- Creating layouts for multiple screens
- Understanding arguments and callback methods
- Passing arguments to a fragment
- Choosing layout at runtime
- Displaying dialogs with fragments
- Using fragments for managing dialogs, shared preferences, and more
Skill Level Intermediate
Duration
Views
-
Introduction
-
Welcome1m 4s
-
What you should know1m 50s
-
Using the exercise files1m 39s
-
-
1. Getting Started
-
Understanding fragments3m 17s
-
2. Display Fragments in Activities
-
Display a fragment with XML3m 16s
-
Add a fragment with Java3m 50s
-
3. Manage Fragments at Runtime
-
Pass arguments to a fragment5m 18s
-
Choose layout at runtime3m 21s
-
-
4. Communication between Fragments and Activities
-
5. Display Dialogs with Fragments
-
Display a custom dialog5m 1s
-
Pass arguments to the dialog4m 16s
-
6. Other Uses of Fragments
-
Create a ViewPager adapter4m 53s
-
Conclusion
-
Next steps1m 11s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Adapting to screen sizes and densities