Example usage for android.support.v4.app AlertDialog.Builder dismiss

List of usage examples for android.support.v4.app AlertDialog.Builder dismiss

Introduction

In this page you can find the example usage for android.support.v4.app AlertDialog.Builder dismiss.

Prototype

void dismiss();

Source Link

Document

Dismisses the dialog, invoking the OnDismissListener .

Usage

From source file:cc.softwarefactory.lokki.android.fragments.PlacesFragment.java

private void renamePlaceDialog(final String placeName) {

    Log.d(TAG, "renamePlaceDialog");
    AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
    final EditText input = new EditText(getActivity());
    String titleFormat = getResources().getString(R.string.rename_place);
    String title = String.format(titleFormat, placeName);

    dialog.setTitle(title).setMessage(R.string.write_place_name).setView(input)
            .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override/*from  ww w. j  a  v  a2s.  c  o  m*/
                public void onClick(DialogInterface dialog, int which) {
                    String newName = input.getText().toString();
                    renamePlace(placeName, newName);
                    dialog.dismiss();
                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    dialog.show();
}