When and why should I use fragments in Android applications? [duplicate]

Fragments are more of a UI benefit in my opinion. It’s convenient for the user sometimes to see two different views of two different classes on the same screen. If, in your moment of creativity, you decide it would be nice to display your application with, say, a listView that takes up half the screen and a webView that takes up the other half – so that when you click on a list item in fragment A it passes an intent to the webView in fragment B, and suddenly you see what you just clicked without the app switching activities – then you could use a fragment. That’s just an example I came up with off the top of my head.

Bottom line: Fragments are two or more activities on the screen at the same time.

Leave a Comment