Changes

Jump to: navigation, search

Using Fragments in Android - A Worked Example

772 bytes added, 16:26, 3 July 2014
Creating the Example Project
== Creating the Example Project ==
Launch Eclipse and create an Android Application Project named FragmentExample with the appropriate package name and SDK selections. As with previous examples, request the creation of a blank activity and the use of the default launcher icons. On the New Blank Activity screen of the New Android Application wizard, set the Activity Name to FragmentExampleActivity and the Layout Name and Fragment names to activity_fragment_exampleand fragment_fragment_activity respectivelyThe objective of this chapter is to work with fragments starting with a clean slate. Since the default Eclipse project already contains a fragment file this will need to be removed before continuing. Within the Project Explorer panel, locate the fragment_fragment_activity.xml file located in the res/layout folder and delete it from the project. Next edit the FragmentExampleActivity.java file and modify the onCreate() method to remove the reference to the placeholder fragment. Also remove the PlaceholderFragment class declaration: <pre>@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fragment_example);} ..}</pre>
== Adding the Android Support Library ==

Navigation menu