void showDialog() { // Create the fragment and show it as a dialog. DialogFragment newFragment = MyDialogFragment.newInstance(); newFragment.show(getFragmentManager(), "dialog"); } //END_INCLUDE(show_dialog)
void showDialog() { // Create the fragment and show it as a dialog. DialogFragment newFragment = MyDialogFragment.newInstance(); newFragment.show(getFragmentManager(), "dialog"); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_dialog_or_activity); if (savedInstanceState == null) { // First-time init; create fragment to embed in activity. FragmentTransaction ft = getFragmentManager().beginTransaction(); DialogFragment newFragment = MyDialogFragment.newInstance(); ft.add(R.id.embedded, newFragment); ft.commit(); } // Watch for button clicks. Button button = (Button)findViewById(R.id.show_dialog); button.setOnClickListener(new OnClickListener() { public void onClick(View v) { showDialog(); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_dialog_or_activity); if (savedInstanceState == null) { // First-time init; create fragment to embed in activity. //BEGIN_INCLUDE(embed) FragmentTransaction ft = getFragmentManager().beginTransaction(); DialogFragment newFragment = MyDialogFragment.newInstance(); ft.add(R.id.embedded, newFragment); ft.commit(); //END_INCLUDE(embed) } // Watch for button clicks. Button button = (Button)findViewById(R.id.show_dialog); button.setOnClickListener(new OnClickListener() { public void onClick(View v) { showDialog(); } }); }