Example usage for android.app Dialog setCancelable

List of usage examples for android.app Dialog setCancelable

Introduction

In this page you can find the example usage for android.app Dialog setCancelable.

Prototype

public void setCancelable(boolean flag) 

Source Link

Document

Sets whether this dialog is cancelable with the KeyEvent#KEYCODE_BACK BACK key.

Usage

From source file:ab.util.AbDialogUtil.java

/**
 * progressDialog/* ww  w  .j av  a  2s .  co m*/
 * 
 * @param context
 * @param msg
 * @return
 */
public static Dialog createLoadingDialog(Context context, String msg) {
    LayoutInflater inflater = LayoutInflater.from(context);
    View v = inflater.inflate(R.layout.herily_alertex_dialog_custom_frame_layout, null);// view
    ProgressWheel spaceshipImage = (ProgressWheel) v.findViewById(R.id.customFrameLoadImg);
    spaceshipImage.stopSpinning();
    spaceshipImage.startSpinning();
    TextView tipTextView = (TextView) v.findViewById(R.id.customFrameMsg);// ??
    tipTextView.setText(msg);// ?
    Dialog loadingDialog = new Dialog(context, R.style.loading_dialog);// ?dialog
    loadingDialog.setCancelable(false);// ????
    loadingDialog.setContentView(v, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
            LinearLayout.LayoutParams.FILL_PARENT));// 
    return loadingDialog;
}

From source file:it.unicaradio.android.activities.MainActivity.java

private void showUpdatesDialog() {
    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.popup);
    dialog.setTitle(R.string.application_updated);
    dialog.setCancelable(true);

    TextView textView = (TextView) dialog.findViewById(R.id.updatesText);
    textView.setText(R.string.updates);/*from   w ww .  ja  va2s.  c  om*/

    Button button = (Button) dialog.findViewById(R.id.updatesButton);
    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.hide();
        }
    });
    dialog.show();
}

From source file:org.anurag.compress.ExtractTarFile.java

public ExtractTarFile(final Context ctx, final Item zFile, final int width, String extractDir, final File file,
        final int mode) {
    // TODO Auto-generated constructor stub
    running = false;//  ww w  .j  a  v a 2s .  c  om
    errors = false;
    prog = 0;
    read = 0;
    final Dialog dialog = new Dialog(ctx, Constants.DIALOG_STYLE);
    dialog.setCancelable(true);
    dialog.setContentView(R.layout.extract_file);
    dialog.getWindow().getAttributes().width = width;
    DEST = extractDir;
    final ProgressBar progress = (ProgressBar) dialog.findViewById(R.id.zipProgressBar);
    final TextView to = (TextView) dialog.findViewById(R.id.zipFileName);
    final TextView from = (TextView) dialog.findViewById(R.id.zipLoc);
    final TextView cfile = (TextView) dialog.findViewById(R.id.zipSize);
    final TextView zsize = (TextView) dialog.findViewById(R.id.zipNoOfFiles);
    final TextView status = (TextView) dialog.findViewById(R.id.zipFileLocation);

    if (extractDir == null)
        to.setText(ctx.getString(R.string.extractingto) + " Cache directory");
    else
        to.setText(ctx.getString(R.string.extractingto) + " " + DEST);

    from.setText(ctx.getString(R.string.extractingfrom) + " " + file.getName());

    if (mode == 2) {
        //TAR ENTRY HAS TO BE SHARED VIA BLUETOOTH,ETC...
        TextView t = null;//= (TextView)dialog.findViewById(R.id.preparing);
        t.setText(ctx.getString(R.string.preparingtoshare));
    }

    try {
        if (file.getName().endsWith(".tar.gz"))
            tar = new TarArchiveInputStream(new GZIPInputStream(new FileInputStream(file)));
        else
            tar = new TarArchiveInputStream(new BufferedInputStream(new FileInputStream(file)));
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
        tar = null;
    }

    final Handler handle = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case 0:

                progress.setProgress(0);
                cfile.setText(ctx.getString(R.string.extractingfile) + " " + name);
                break;

            case 1:
                status.setText(name);
                progress.setProgress((int) prog);
                break;
            case 2:
                try {
                    tar.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                if (running) {
                    dialog.dismiss();
                    if (mode == 0) {
                        //after extracting file ,it has to be opened....
                        new OpenFileDialog(ctx, Uri.parse(dest));
                    } else if (mode == 2) {
                        //FILE HAS TO BE SHARED....
                        new BluetoothChooser(ctx, new File(dest).getAbsolutePath(), null);
                    } else {
                        if (errors)
                            Toast.makeText(ctx, ctx.getString(R.string.errorinext), Toast.LENGTH_SHORT).show();
                        Toast.makeText(ctx, ctx.getString(R.string.fileextracted), Toast.LENGTH_SHORT).show();
                    }
                }

                break;
            case 3:
                zsize.setText(size);
                progress.setMax((int) max);
                break;
            case 4:
                status.setText(ctx.getString(R.string.preparing));
                break;
            case 5:
                running = false;
                Toast.makeText(ctx, ctx.getString(R.string.extaborted), Toast.LENGTH_SHORT).show();
            }
        }
    };

    final Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
            // TODO Auto-generated method stub
            if (running) {
                if (DEST == null) {
                    DEST = Environment.getExternalStorageDirectory() + "/Android/data/org.anurag.file.quest";
                    new File(DEST).mkdirs();
                }

                TarArchiveEntry ze;
                try {
                    while ((ze = tar.getNextTarEntry()) != null) {
                        if (ze.isDirectory())
                            continue;
                        handle.sendEmptyMessage(4);
                        if (!zFile.isDirectory()) {
                            //EXTRACTING A SINGLE FILE FROM AN ARCHIVE....
                            if (ze.getName().equalsIgnoreCase(zFile.t_getEntryName())) {
                                try {

                                    //SENDING CURRENT FILE NAME....
                                    try {
                                        name = zFile.getName();
                                    } catch (Exception e) {
                                        name = zFile.t_getEntryName();
                                    }
                                    handle.sendEmptyMessage(0);
                                    dest = DEST;
                                    dest = dest + "/" + name;
                                    FileOutputStream out = new FileOutputStream((dest));
                                    max = ze.getSize();
                                    size = AppBackup.size(max, ctx);
                                    handle.sendEmptyMessage(3);
                                    InputStream fin = tar;
                                    while ((read = fin.read(data)) != -1 && running) {
                                        out.write(data, 0, read);
                                        prog += read;
                                        name = AppBackup.status(prog, ctx);
                                        handle.sendEmptyMessage(1);
                                    }
                                    out.flush();
                                    out.close();
                                    fin.close();
                                    break;
                                } catch (FileNotFoundException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                    //errors = true;
                                } catch (IOException e) {
                                    errors = true;
                                }
                            }
                        } else {
                            //EXTRACTING A DIRECTORY FROM TAR ARCHIVE....
                            String p = zFile.getPath();
                            if (p.startsWith("/"))
                                p = p.substring(1, p.length());
                            if (ze.getName().startsWith(p)) {
                                prog = 0;
                                dest = DEST;
                                name = ze.getName();
                                String path = name;
                                name = name.substring(name.lastIndexOf("/") + 1, name.length());
                                handle.sendEmptyMessage(0);

                                String foname = zFile.getPath();
                                if (!foname.startsWith("/"))
                                    foname = "/" + foname;

                                if (!path.startsWith("/"))
                                    path = "/" + path;
                                path = path.substring(foname.lastIndexOf("/"), path.lastIndexOf("/"));
                                if (!path.startsWith("/"))
                                    path = "/" + path;
                                dest = dest + path;
                                new File(dest).mkdirs();
                                dest = dest + "/" + name;

                                FileOutputStream out;
                                try {
                                    max = ze.getSize();
                                    out = new FileOutputStream((dest));
                                    size = AppBackup.size(max, ctx);
                                    handle.sendEmptyMessage(3);

                                    //   InputStream fin = tar;
                                    while ((read = tar.read(data)) != -1 && running) {
                                        out.write(data, 0, read);
                                        prog += read;
                                        name = AppBackup.status(prog, ctx);
                                        handle.sendEmptyMessage(1);
                                    }
                                    out.flush();
                                    out.close();
                                    //fin.close();
                                } catch (FileNotFoundException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                    //   errors = true;
                                } catch (IOException e) {
                                    errors = true;
                                } catch (Exception e) {
                                    //errors = true;
                                }
                            }
                        }
                    }
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                    errors = true;
                }
                handle.sendEmptyMessage(2);
            }
        }
    });
    /*
    Button cancel = (Button)dialog.findViewById(R.id.calcelButton);
    cancel.setOnClickListener(new View.OnClickListener() {
       @Override
       public void onClick(View arg0) {
    // TODO Auto-generated method stub
    dialog.dismiss();
    handle.sendEmptyMessage(5);
       }
    });
    Button st = (Button)dialog.findViewById(R.id.extractButton);
    st.setVisibility(View.GONE);*/

    dialog.show();
    running = true;
    thread.start();
    dialog.setCancelable(false);
    progress.setVisibility(View.VISIBLE);
}

From source file:com.smsc.usuario.ui.MapaActivity.java

public void getDetalle(int posicion) {
    final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCancelable(false);
    dialog.setContentView(R.layout.dialog_incidente);

    TextView lblAsunto = (TextView) dialog.findViewById(R.id.lblAsunto);
    lblAsunto.setText(lista.get(posicion).getStr_detalle());

    TextView lblNombreInciente = (TextView) dialog.findViewById(R.id.lblNombreInciente);
    lblNombreInciente.setText(lista.get(posicion).getStr_tipo_incidente_nombre());

    TextView lblEstado = (TextView) dialog.findViewById(R.id.lblEstado);
    lblEstado.setText("Enviado");
    if (lista.get(posicion).getInt_estado() == 1)
        lblEstado.setText("En Progreso");
    else if (lista.get(posicion).getInt_estado() == 2)
        lblEstado.setText("Valido");
    else if (lista.get(posicion).getInt_estado() == 3)
        lblEstado.setText("Invalido");
    SimpleDateFormat fecha = new SimpleDateFormat("dd/MM/yyyy");
    SimpleDateFormat hora = new SimpleDateFormat("h:mm a");

    TextView lblFecha = (TextView) dialog.findViewById(R.id.lblFecha);
    lblFecha.setText(fecha.format(lista.get(posicion).getDat_fecha_registro()));

    TextView lblHora = (TextView) dialog.findViewById(R.id.lblHora);
    lblHora.setText(hora.format(lista.get(posicion).getDat_fecha_registro()));

    View ViewFoto = (View) dialog.findViewById(R.id.ViewFoto);
    if (lista.get(posicion).getByte_foto() == null) {
        ViewFoto.setVisibility(View.GONE);
    } else {/*w  w  w .  j a  va  2s.co  m*/
        ImageView image = (ImageView) dialog.findViewById(R.id.image);
        image.setImageBitmap(Funciones.getBitmap(lista.get(posicion).getByte_foto()));
    }

    View ViewCalificacion = (View) dialog.findViewById(R.id.ViewCalificacion);
    if (lista.get(posicion).getInt_rapides() == 0 && lista.get(posicion).getInt_conformidad() == 0) {
        ViewCalificacion.setVisibility(View.GONE);
    } else {
        RatingBar ratingRapides = (RatingBar) dialog.findViewById(R.id.ratingRapides);
        ratingRapides.setRating(lista.get(posicion).getInt_rapides());

        RatingBar ratingConformidad = (RatingBar) dialog.findViewById(R.id.ratingConformidad);
        ratingConformidad.setRating(lista.get(posicion).getInt_conformidad());
    }

    Button btnAceptar = (Button) dialog.findViewById(R.id.btnAceptar);
    btnAceptar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
    dialog.show();

}

From source file:com.polyvi.xface.extension.inappbrowser.XInAppBrowser.java

/**
 * ???/*from  w  w  w .j  a v  a  2  s  . c  om*/
 * @param theme 
 * @param animation 
 * @param windowFeature ?
 * @return dialog
 */
protected Dialog createDialog(int theme, int animation, int windowFeature) {
    Dialog dialog = new Dialog(mContext, theme);
    dialog.getWindow().getAttributes().windowAnimations = animation;
    dialog.requestWindowFeature(windowFeature);
    dialog.setCancelable(true);
    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        public void onDismiss(DialogInterface dialog) {
            mBrowserListener.onDismiss(mWebContext);
        }
    });
    return dialog;
}

From source file:com.idt.ontomedia.geoconsum.BaseActivity.java

private Dialog setDialogWithCheck(int _id) {
    final Dialog dialog = new Dialog(this);

    dialog.setContentView(R.layout.dialog_with_check);

    TextView textViewInfo = (TextView) dialog.findViewById(R.id.text_layout);
    CheckBox checkBox = (CheckBox) dialog.findViewById(R.id.checkBox1);

    switch (_id) {
    case DIALOG_ABOUT_ID: {
        dialog.setTitle(getResources().getString(R.string.dialog_title_about) + " "
                + getResources().getString(R.string.app_name));
        dialog.setCancelable(true);

        checkBox.setVisibility(View.GONE);

        ImageView imageViewBanner = (ImageView) dialog.findViewById(R.id.imageViewBanner);
        imageViewBanner.setImageDrawable(getResources().getDrawable(R.drawable.logo_idt));
        imageViewBanner.setVisibility(View.VISIBLE);

        textViewInfo.setText(R.string.dialog_text_about);
    }//from  www  . j a v  a 2 s . co  m
    case DIALOG_WARNING_ID: {
        dialog.setTitle(getResources().getString(R.string.dialog_title_warning));
        dialog.setCancelable(false);

        textViewInfo.setText(R.string.dialog_text_warning);

        checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton _buttonView, boolean _isChecked) {
                SharedPreferences sharedPreferences = PreferenceManager
                        .getDefaultSharedPreferences(getBaseContext());
                SharedPreferences.Editor editor = sharedPreferences.edit();
                editor.putBoolean(DialogPreferenceActivity.PREF_DIALOG_CHECK, _isChecked);
                editor.commit();
            }
        });
    }
    }

    Button acceptButton = (Button) dialog.findViewById(R.id.button1);
    acceptButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.cancel();
        }

    });

    return dialog;
}

From source file:com.amazon.appstream.fireclient.ConnectDialogFragment.java

/**
 * Create callback; performs initial set-up.
 *//*w  ww . ja v  a  2s . c om*/
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mEmpty.setAlpha(0);

    final Dialog connectDialog = new Dialog(getActivity());
    connectDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    connectDialog.setCanceledOnTouchOutside(false);
    connectDialog.setCancelable(false);
    connectDialog.setContentView(R.layout.server_address);
    connectDialog.getWindow().setBackgroundDrawable(mEmpty);

    mAddressTitle = (TextView) connectDialog.findViewById(R.id.address_title);

    mAddressField = (TextView) connectDialog.findViewById(R.id.address);

    mTextEntryFields = connectDialog.findViewById(R.id.text_entry_fields);
    mProgressBar = (ProgressBar) connectDialog.findViewById(R.id.progress_bar);

    mUseHardware = (CheckBox) connectDialog.findViewById(R.id.hardware);
    mUseHardware.setChecked(false);

    final CheckBox useAppServerBox = (CheckBox) connectDialog.findViewById(R.id.appserver);
    useAppServerBox.setChecked(mUseAppServer);
    useAppServerBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            if (isChecked) {
                if (!mUseAppServer) {
                    mDESServerAddress = mAddressField.getText().toString();
                }
            } else {
                if (mUseAppServer) {
                    mServerAddress = mAddressField.getText().toString();
                }
            }
            mUseAppServer = isChecked;
            updateFields();
        }
    });

    mAppIdField = (TextView) connectDialog.findViewById(R.id.appid);

    mSpace1 = connectDialog.findViewById(R.id.space1);
    mSpace2 = connectDialog.findViewById(R.id.space2);
    mAppIdTitle = connectDialog.findViewById(R.id.appid_title);
    mUserIdTitle = connectDialog.findViewById(R.id.userid_title);

    if (mAppId != null) {
        mAppIdField.setText(mAppId);
    }

    mUserIdField = (TextView) connectDialog.findViewById(R.id.userid);

    if (mUsername != null) {
        mUserIdField.setText(mUsername);
    }

    mErrorMessageField = (TextView) connectDialog.findViewById(R.id.error_message);

    mReconnect = connectDialog.findViewById(R.id.reconnect_fields);
    mReconnectMessage = (TextView) connectDialog.findViewById(R.id.reconnect_message);

    final Button connectButton = (Button) connectDialog.findViewById(R.id.connect);
    connectButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            onConnect();
        }
    });

    TextView.OnEditorActionListener listener = new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_GO) {
                InputMethodManager imm = (InputMethodManager) mActivity
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(mUserIdField.getWindowToken(), 0);
                onConnect();
            }
            return true;
        }
    };

    View.OnFocusChangeListener focusListener = new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            connectButton.setFocusableInTouchMode(false);
        }
    };

    mAppIdField.setOnFocusChangeListener(focusListener);
    mUserIdField.setOnFocusChangeListener(focusListener);
    mUserIdField.setOnFocusChangeListener(focusListener);
    mUserIdField.setOnEditorActionListener(listener);

    updateFields();
    if (mAddressField.getText().length() == 0) {
        mAddressField.requestFocus();
        connectButton.setFocusableInTouchMode(false);
    } else {
        connectButton.requestFocus();
    }

    if (mReconnectMessageString != null) {
        reconnecting(mReconnectMessageString);
        mReconnectMessageString = null;
    }

    return connectDialog;
}

From source file:com.vk.sdk.dialogs.VKShareDialog.java

@NonNull
@Override/*  w  w w  . ja va2 s. c om*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context context = getActivity();
    View mInternalView = LayoutInflater.from(context).inflate(R.layout.vk_share_dialog, null);

    assert mInternalView != null;

    mSendButton = (Button) mInternalView.findViewById(R.id.sendButton);
    mSendProgress = (ProgressBar) mInternalView.findViewById(R.id.sendProgress);
    mPhotoLayout = (LinearLayout) mInternalView.findViewById(R.id.imagesContainer);
    mShareTextField = (EditText) mInternalView.findViewById(R.id.shareText);
    mPhotoScroll = (HorizontalScrollView) mInternalView.findViewById(R.id.imagesScrollView);

    LinearLayout mAttachmentLinkLayout = (LinearLayout) mInternalView.findViewById(R.id.attachmentLinkLayout);

    mSendButton.setOnClickListener(sendButtonPress);

    //Attachment text
    if (savedInstanceState != null) {
        mShareTextField.setText(savedInstanceState.getString(SHARE_TEXT_KEY));
        mAttachmentLink = savedInstanceState.getParcelable(SHARE_LINK_KEY);
        mAttachmentImages = (VKUploadImage[]) savedInstanceState.getParcelableArray(SHARE_IMAGES_KEY);
        mExistingPhotos = savedInstanceState.getParcelable(SHARE_UPLOADED_IMAGES_KEY);
    } else if (mAttachmentText != null) {
        mShareTextField.setText(mAttachmentText);
    }

    //Attachment photos
    mPhotoLayout.removeAllViews();
    if (mAttachmentImages != null) {
        for (VKUploadImage mAttachmentImage : mAttachmentImages) {
            addBitmapToPreview(mAttachmentImage.mImageData);
        }
        mPhotoLayout.setVisibility(View.VISIBLE);
    }

    if (mExistingPhotos != null) {
        processExistingPhotos();
    }
    if (mExistingPhotos == null && mAttachmentImages == null) {
        mPhotoLayout.setVisibility(View.GONE);
    }

    //Attachment link
    if (mAttachmentLink != null) {
        TextView linkTitle = (TextView) mAttachmentLinkLayout.findViewById(R.id.linkTitle),
                linkHost = (TextView) mAttachmentLinkLayout.findViewById(R.id.linkHost);

        linkTitle.setText(mAttachmentLink.linkTitle);
        linkHost.setText(VKUtil.getHost(mAttachmentLink.linkUrl));
        mAttachmentLinkLayout.setVisibility(View.VISIBLE);
    } else {
        mAttachmentLinkLayout.setVisibility(View.GONE);
    }
    Dialog result = new Dialog(context);
    result.requestWindowFeature(Window.FEATURE_NO_TITLE);
    result.setContentView(mInternalView);
    result.setCancelable(true);
    result.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialogInterface) {
            if (mListener != null) {
                mListener.onVkShareCancel();
            }
            VKShareDialog.this.dismiss();
        }
    });
    return result;
}

From source file:io.github.jhcpokemon.expressassist.fragment.SettingFragment.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.clear:
        SharedPreferences sharedPreferences = getContext().getSharedPreferences("user_msg",
                Context.MODE_APPEND);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString("email", "");
        editor.putString("password", "");
        editor.putBoolean("save", false);
        editor.putBoolean("auto", false);
        editor.apply();/*www  .j a  va  2s. com*/
        ExpressLog.deleteAll(ExpressLog.class);
        getActivity().finishAffinity();
        break;
    case R.id.version:
        if (count == 0) {
            Dialog imageDialog = new Dialog(getContext());
            ViewGroup.LayoutParams params = imageDialog.getWindow().getAttributes();
            params.width = WindowManager.LayoutParams.MATCH_PARENT;
            params.height = WindowManager.LayoutParams.MATCH_PARENT;
            imageDialog.getWindow().setAttributes((WindowManager.LayoutParams) params);
            imageDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
            imageDialog.setContentView(R.layout.image_dialog);
            imageDialog.setCancelable(true);
            imageDialog.show();
            versionBtn.setClickable(false);
        } else {
            count--;
        }
        break;
    case R.id.policy:
        Dialog policyDialog = new Dialog(getContext()) {
            @Override
            protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setTitle(R.string.policy);
                View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_policy, null, false);
                TextView policyTextView = (TextView) view.findViewById(R.id.policy);
                policyTextView.setText(policy);
                setContentView(view);
                setCancelable(true);
                ViewGroup.LayoutParams params = getWindow().getAttributes();
                params.width = WindowManager.LayoutParams.MATCH_PARENT;
                getWindow().setAttributes((WindowManager.LayoutParams) params);
            }
        };

        policyDialog.show();
        break;
    default:
        break;
    }
}

From source file:com.android.nobadgift.DashboardActivity.java

private void displayConfirmationDialog() {
    try {//from  www.ja  v a2 s.c o m
        Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.custom_dialog);
        dialog.setTitle("Successfully Scanned!");
        dialog.setCanceledOnTouchOutside(true);
        dialog.setCancelable(true);
        dialog.setOnDismissListener(new OnDismissListener() {
            public void onDismiss(DialogInterface dialog) {
                displayInfoDialog();
            }
        });
        TextView text = (TextView) dialog.findViewById(R.id.dialogText);
        text.setText("\"" + itemName + "\"");
        ImageView image = (ImageView) dialog.findViewById(R.id.dialogImage);
        image.setImageBitmap(retrievedImage);
        dialog.show();
    } catch (Exception e) {
        e.printStackTrace();
    }
}