0

I'm a bit confused as to wether I should create a plain activity or a fragmentactivity. My app is displaying an expandableListView and a dialog. Thats it (pretty much).

I cannot find any instance that my app would be better if I used a fragmentActivtiy because first of all my app is not designed for tablets, and second I'm not adding or doing anything to my main activity during runtime to change the views.

My problem is that it seems it is a must to use fragments, because when I checked out Android dev site on dialogs, it only explains how to implement them using fragments. Are plain activities highly un-recommended or I just have to judge my app, and are all features such as dialogs available for plain activities? (And can someone please give me a link to a good source where I can learn about dialogs in a normal activity?)

http://developer.android.com/guide/topics/ui/dialogs.html

It says here that you should use a fragment but does that mean i have to go all out and make my main activity a fragment?

Izak
  • 909
  • 9
  • 24
  • 1
    As long as your Dialog is concerned you can use AlertDialog and inflate an xml of your own choice and set that xml as view using `alertDialog.setView(view)` method. – Zubair Ahmed Apr 29 '15 at 04:25

2 Answers2

0

Here is some discussion about using Fragment or Activity for dialog: Show fragment as a dialog or as a usual activity

If you want to make your dialog as Activity, hope this tutorial helps: How to create Dialog activity in Android?

Community
  • 1
  • 1
Tuan Hoang
  • 586
  • 1
  • 7
  • 14
0

A FragmentActivity is an Activity because it extends Activity See here. The question the mean to ask is really a question for your self, do you want your app to support API >= 11 (3.0 Honeycomb) or API >= 4?

In API 11 Android introduced the concept of Fragments to deal with creating apps particularly tablets. But to add support for all the devices still running < 11 they created the Support v4 library which is where FragmentActivity lives.

If you are not using Fragments at all then just use Activity because it's available at all API levels. (it just got added functionality in >=11). If you want to support >=4 and may use Fragments then use FragmentActivity and your covered. I noticed things in the v4 library have started to be deprecated (starting to be phased out by Google). Personally, I won't make a new app with API <14 and suggest you stay above 11.

As far as Dialogs go. You don't need to used a DialogFragment but same question above applies to API level. I typically just used Dialog to show mine even if I'm using Fragments.

Hopefully this clears some things up for you. Happy Codin'

kev
  • 2,306
  • 3
  • 26
  • 31