Professional Documents
Culture Documents
L12 - Android Fragments
L12 - Android Fragments
Android Fragments
Content
Button to ImageButton
Logic for Quiz
Launcher Icon
Android fragments
2
Rahul Talreja, Neusoft
UI Flexibility
You might imagine that a list-detail application consists of two
activities: one managing the list and the other managing the detail
view.
Clicking a crime in the list would start an instance of the detail
activity.
Pressing the Back button would destroy the detail activity and
return you to the list where you could select another list.
3
UI Flexibility
4
Rahul Talreja, Neusoft
Fragments
A fragment is a controller object that an activity can deputize to
perform tasks. Most commonly, the task is managing a user
interface. The user interface can be an entire screen or just one
part of the screen.
5
Fragments
The activity’s view technically stays the same throughout its
lifetime, and no laws of Android are violated.
The detail view would show the details of the selected list item.
Selecting another item should display a new detail view. This is
easy with fragments; the activity will replace the detail fragment
with another detail fragment.
No activities need to die for this major view change to happen.
6
Fragments
7
Rahul Talreja, Neusoft 8