Example usage for android.support.v4.app.support DialogFragment show

List of usage examples for android.support.v4.app.support DialogFragment show

Introduction

In this page you can find the example usage for android.support.v4.app.support DialogFragment show.

Prototype

public int show(FragmentTransaction transaction, String tag) 

Source Link

Document

Display the dialog, adding the fragment using an existing transaction and then committing the transaction.

Usage

From source file:com.github.preferencefragment.app.FragmentAlertDialog.java

void showDialog() {
    DialogFragment newFragment = MyAlertDialogFragment.newInstance(R.string.alert_dialog_two_buttons_title);
    newFragment.show(getSupportFragmentManager(), "dialog");
}

From source file:com.github.preferencefragment.app.FragmentDialog.java

void showDialog() {
    mStackLevel++;//  w  w w  .  j  a v  a  2s  .c  o  m

    // DialogFragment.show() will take care of adding the fragment
    // in a transaction. We also want to remove any currently showing
    // dialog, so make our own transaction and take care of that here.
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    Fragment prev = getSupportFragmentManager().findFragmentByTag("dialog");
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);

    // Create and show the dialog.
    DialogFragment newFragment = MyDialogFragment.newInstance(mStackLevel);
    newFragment.show(ft, "dialog");
}