Android Fragments Example :
A fragment represents a portion of a user interface or an operation that runs within an activity.
A single activity can contain multiple fragments and many fragments can be reused in many, different activities. It is not wrong if we say that a fragment is a type of sub-activity that can be utilised again in multiple activities.
Although each fragment has each own lifecycle, it is connected with the activity it belongs to, so its lifecycle is directly influenced by the activity’s lifecycle.
The main advantage of using fragments is due to the convenience of reusing the components in different layouts. In this tutorial, we are going to create our own fragments, where each one will be used when the user presses the appropriate button.
0 comments: