Note: Adding a fragment at runtime is a good practice. So basically there are two ways to do so. Now let’s first talk about how many ways we can create and add fragments to our activity. This is how fragments are very important in terms of uses and also to increase the flexibility of our product. But if you talk about a simple mobile device then you can start a new activity and then in that new activity, you can use the fragment to the upcoming songs. ![]() This can be down by using fragment without worrying about the complex design of the application. ![]() here what you can do is you can divide a screen into two parts, on the left side of the screen you can show a list of all the songs and on the right you can show the currently playing song. Now consider the scenario where you are using a tablet. Fragments allow such designs without the need for you to manage complex changes to the view hierarchy.įor example, suppose you are building a music app. Because a tablet’s screen is much larger than that of a handset, there’s more room to combine and interchange UI components. In other words, we get more flexibility using fragments.įragments are used primarily to support more dynamic and flexible UI designs on large screens, such as tablets. So, here is the reason that why we use them:īefore fragment introduction, we only able to show a single activity on the screen and not able to divide the screen into different parts but after the fragments, boom! we can add as many subactivities as we want for our screen which makes our android application more useful.
0 Comments
Leave a Reply. |