Changes

Jump to: navigation, search

Using Fragments in Android Studio - An Example

195 bytes added, 16:17, 11 January 2019
no edit summary
 
As outlined in the previous chapter, fragments provide a convenient mechanism for creating reusable modules of application functionality consisting of both sections of a user interface and the corresponding behavior. Once created, fragments can be embedded within activities.
Having explored the overall theory of fragments in the previous chapter, the objective of this chapter is to create an example Android application using Android Studio designed to demonstrate the actual steps involved in both creating and using fragments, and also implementing communication between one fragment and another within an activity.
== About About the Example Fragment Application ==
The application created in this chapter will consist of a single activity and two fragments. The user interface for the first fragment will contain a toolbar of sorts consisting of an EditText view, a SeekBar and a Button, all contained within a RelativeLayout view. The second fragment will consist solely of a TextView object, also contained within a RelativeLayout view.
[[Image:as3.0_fragment_add_layout.png]]
[[Image:as3.0_fragment_layout_1.png]]
[[Image:as3.0_fragment_layout_2.png]]
[[Image:as3.0_add_fragment_to_layout.png]]
[[Image:as_3.2_select_fragment.png]]
[[Image:as3.0_fragment_unknown.png]]
[[Image:as3.0_fragment_ui_finished.png]]
[[Image:as3.0_fragment_example_running.png]]

Navigation menu