Here are some important learnings for displaying a user dialog fragment. Steps to create:
- Create a new layout file for the dialog.
- Create a new Java class to inflate the fragment. This should extend the Android system DialogFragment class.
- Create reference in the main activity to inflate the dialog
public void showDialog(View v){
FragmentManager manager = getFragmentManager();
FragmentDialog addDialog = new FragmentDialog();
addDialog.show(manager, "addDialog");
}
You can see I am making use of two new objects:
- FragmentDialog --> This is the class I created to inflate the new xml layout
- FragmentManager --> Android system object used as an interface for dealing with fragments
Helpful resources:
No comments:
Post a Comment