Essah
Essah

Reputation: 929

Fragments or Activity for my Android App

I have spent a little while trying to research the differences between Fragment and Activities but haven't found any conclusion. this thread seems to recommend fragments Are Fragments and Fragment Activities inherently faster than Activities?

while this one Activities (for Phones) Android Fragments and Activities

I'm developing an App where the user will first be presented with a search screen, on which he will set up search details and then after clicking search, he will be shown another screen, with a list of the search results. I can't judge which solution to go with. A) should I go with activity or Fragments. I am not going to be using the actionbar on either screen.

It might be relevant to make a tablet version of the app in the future in which case I imagine fragments will be useful but B) is it a major headache to redesign from activies to using fragments instead?

C) when using fragments, can you have screen-A be your main activity and Screen-B your fragment-#1 or do you have to make both screens as a fragment with the main activity as parent.

Upvotes: 1

Views: 400

Answers (1)

Joe C
Joe C

Reputation: 184

If I understand the scope of your goal correctly you would be better off going with fragments. This is because fragments really are what they sound like. Fragments of code that can be reused elsewhere. My gut tells me having a search result be available for easy reuse would benefit the app in cases of a query in the future or simply using the results as some kind of auto-fill option. Fragments aren't much different than Activities from their structure but there ARE differences to know. If you have not implemented Activities already consider using fragments. As far as point C in your post, you can do both scenarios you asked about. I have an app that my main activity is "in the background" and switches between 2 fragments as the user navigates. Another example would be a weather app using the main activity as screen 1 and a fragment as screen 2.

Check out this guy on Youtube for some really good (and simple) fragment explanations.

Upvotes: 1

Related Questions