Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 8

Android Development

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.

A fragment managing a user interface is known as a UI


fragment. A UI fragment has a view of its own that is inflated
from a layout file.

You can use the fragment(s) associated with the activity to


compose and re-compose the screen as and when needed.

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

You might also like