Changes

Jump to: navigation, search

Using Fragments in Android - A Worked Example

83 bytes removed, 19:41, 26 June 2013
no edit summary
<table border="0" cellspacing="0" width="100%">
<tr>
<td width="20%">[[An Introduction to Android Fragments|Previous]]<td align="center">[[Kindle Fire Android 4 App Development Essentials|Table of Contents]]<td width="20%" align="right">[[Creating and Managing An Android Overflow Menus on the Kindle FireMaster/Detail Flow Tutorial|Next]]</td>
<tr>
<td width="20%">An Introduction to Android Fragments<td align="center"><td width="20%" align="right">Creating and Managing An Android Overflow Menus on the Kindle FireMaster/Detail Flow Tutorial</td>
</table>
<hr>
<google>BUY_KINDLE_FIREBUY_ANDROID</google>
As previously discussed, support for fragments was not introduced until Android 3.0. This means that for applications that make use of fragments to be compatible with the first generation Kindle Fire, use must be made of version 4 of the Android Support Library. The purpose of the Android Support Library is to make features that were introduced in later versions of Android available to applications that need to be compatible with earlier Android versions.
Assuming that the installation steps outlined in the chapter entitled [[Setting up a Kindle Fire Android Development Environment]] were followed, then the Android Support Library package should already be installed on your development system. To verify this, launch Eclipse and select the Window -> Android SDK Manager menu option. When the manager window has appeared on the screen, scroll down to the Extras section and make sure that the column to the far right of the Kindle Fire Support Library item is listed as Installed as shown in Figure 2122-1:
[[Image:android_verify_support_library.png|Checking the Android Support Library package is installed]]
Figure 2122-1
[[Image:android_support_library_added.png|The android support library in the Eclipse Package Explorer]]
Figure 2122-2
</pre>
Once the changes have been made, switch back to the Graphical Layout view of the user interface. Edit the text displayed on the button, creating a new string resource named button_text that reads “Change Text”. Upon completion of these steps, the user interface layout should resemble that of Figure 2122-3
[[Image:android_fragment_one_ui.png|The UI for the first Fragment]]
Figure 2122-3
</pre>
Once the XML changes have been made, switch back to the Graphical Layout view of the user interface. Edit the text displayed on the TextView, creating a new string resource named text_label that reads “Fragment Two”. Upon completion of these steps, the user interface layout for this second fragment should resemble that of Figure 2122-4:
[[Image:android_fragment_two_ui.png|The UI for the second Fragment]]
Figure 2122-4
</pre>
Click on the Graphical Layout tab to return to the graphical view and note that the fragments are now visible in the layout as demonstrated in Figure 2122-5:
[[Image:android_fragments_embedded.png|The user interface for an Android Fragment example application]]
Figure 2122-5
[[Image:kindle_fire_fragment_example_runningandroid_fragment_example_running.png|An Android Fragment example running]]
Figure 2122-6
<google>BUY_KINDLE_FIREBUY_ANDROID</google>
<table border="0" cellspacing="0" width="100%">
<tr>
<td width="20%">[[An Introduction to Android Fragments|Previous]]<td align="center">[[Kindle Fire Android 4 App Development Essentials|Table of Contents]]<td width="20%" align="right">[[Creating and Managing Android Overflow Menus on the Kindle Fire|Next]]</td>
<tr>
<td width="20%">An Introduction to Android Fragments<td align="center"><td width="20%" align="right">Creating and Managing An Android Overflow Menus on the Kindle FireMaster/Detail Flow Tutorial</td>
</table>

Navigation menu