Reputation: 1849
I have created a Fragment by extending Fragment in the support package(v4). This view contains a list and a button. My application supports both phone and 10" Tablet. In Phone I use the fragment to display it as a normal screen using Activity In Tab I need to display the same view as a dialog. Will i be able to reuse the fragment for showing a Dialog?
Upvotes: 2
Views: 2940
Reputation: 3179
I guess that depends on if you just want the layout, or if you want the logic behind it. You can use the same layout in a dialog but the logic is generally implemented differently because dialogs are simpler and use basic implementations to things like ok/cancel. They have access to views in the dialog but there isn't a great place for inserting a fragment.
There is a separate class called DialogFragment referenced here: http://android-developers.blogspot.com/2012/05/using-dialogfragments.html
It says "the showDialog / dismissDialog methods in Activity are being deprecated in favor of DialogFragments"
Upvotes: 1