So as to cater for the larger screens found on tablet devices, Android introduced the android.app.fragment package with version 3.0 (API level 11). Fragments simplify the process of designing and displaying multi-pane screens and are similar to layouts and view groups but provide some of the functionality of activities.
This recipe will demonstrate how to open a fragment from a list and how to control content.
Start a new Android project in Eclipse, making sure that the target build is API level 11 or higher by including the following tag to the <manifest>
element of the manifest file:
<uses-sdk android:targetSdkVersion="11" />
The main layout for this example is a horizontal, LinearLayout containing a ListView and a fragment. The complete
main.xml
code looks like the lines below but substitute the package name in the class declaration with that of your own project:<?xml version="1.0" encoding="utf-8"?> <LinearLayout...