DialogFragment
-
a subclass of Fragment
-
floats on top of activity that contains it and displayed modally
-
create class that extends DialogFragments (e.g. Fragment1)
-
In your Activity create and display DialogFragment:
-
Fragment1 dialogFragment = Fragment1.newInstance("your question to user?"); //newInstance (see full code ) is method to create an instace and setup Bundle of arguments attach to fragment --the string message dialogFragment.show(getFragmentManger(), "dialog"); //associate it with tag "dialog"
-
- EXAMPLE: Activity that in code creates instance of DialogFragment class called Fragment1 and then also reads in answer user selects
- Note: Fragment1 is setup in code to have setPositiveButton("OK",*) and setNegativeButton("Cancel", *)---see full code
- Note: Fragment1 is setup in code to have setPositiveButton("OK",*) and setNegativeButton("Cancel", *)---see full code
- (see Books/Android/Source Code/DialogFragmentExample)