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:com.zpwebsites.linuxonandroid.Install_Debian_Testing_2.java

private void downloads(Context context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.download_debian_menu);
    dialog.setCancelable(true);

    Button btn_DownloadLarge = (Button) dialog.findViewById(R.id.btn_DownloadLarge);
    btn_DownloadLarge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Large_ext4,
                        CFG.imageURL_Debian_Testing_Large_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Large_ext2,
                        CFG.imageURL_Debian_Testing_Large_ext2);
            }//from w ww  . j  a  va 2  s  .co  m
            dialog.dismiss();
        }
    });

    Button btn_DownloadSmall = (Button) dialog.findViewById(R.id.btn_DownloadSmall);
    btn_DownloadSmall.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Small_ext4,
                        CFG.imageURL_Debian_Testing_Small_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Small_ext2,
                        CFG.imageURL_Debian_Testing_Small_ext2);
            }
            dialog.dismiss();
        }
    });

    Button btn_DownloadCore = (Button) dialog.findViewById(R.id.btn_DownloadCore);
    btn_DownloadCore.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Core_ext4,
                        CFG.imageURL_Debian_Testing_Core_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Debian_Testing_Core_ext2,
                        CFG.imageURL_Debian_Testing_Core_ext2);
            }
            dialog.dismiss();
        }
    });
    dialog.show();
}

From source file:com.zpwebsites.linuxonandroid.Install_Ubuntu1310_2.java

private void downloads(Context context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.download_ubuntu1310_menu);
    dialog.setCancelable(true);

    Button btn_DownloadLarge = (Button) dialog.findViewById(R.id.btn_DownloadLarge);
    btn_DownloadLarge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu1310_Large_ext4,
                        CFG.imageURL_Ubuntu1310_Large_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu1310_Large_ext2,
                        CFG.imageURL_Ubuntu1310_Large_ext2);
            }//w w  w  .j  a v  a2 s  .  c  om
            dialog.dismiss();
        }
    });

    Button btn_DownloadSmall = (Button) dialog.findViewById(R.id.btn_DownloadSmall);
    btn_DownloadSmall.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu1310_Small_ext4,
                        CFG.imageURL_Ubuntu1310_Small_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu1310_Small_ext2,
                        CFG.imageURL_Ubuntu1310_Small_ext2);
            }
            dialog.dismiss();
        }
    });

    Button btn_DownloadCore = (Button) dialog.findViewById(R.id.btn_DownloadCore);
    btn_DownloadCore.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu1310_Core_ext4,
                        CFG.imageURL_Ubuntu1310_Core_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu1310_Core_ext2,
                        CFG.imageURL_Ubuntu1310_Core_ext2);
            }
            dialog.dismiss();
        }
    });
    dialog.show();
}

From source file:com.zpwebsites.linuxonandroid.Install_Ubuntu13_2.java

private void downloads(Context context) {
    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.download_ubuntu13_menu);
    dialog.setCancelable(true);

    Button btn_DownloadCore = (Button) dialog.findViewById(R.id.btn_DownloadCore);
    btn_DownloadCore.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Core_ext4,
                        CFG.imageURL_Ubuntu13_Core_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Core_ext2,
                        CFG.imageURL_Ubuntu13_Core_ext2);
            }/*from  ww  w. ja  v a  2 s.  co m*/
            dialog.dismiss();
        }
    });

    Button btn_DownloadLarge = (Button) dialog.findViewById(R.id.btn_DownloadLarge);
    btn_DownloadLarge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Large_ext4,
                        CFG.imageURL_Ubuntu13_Large_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Large_ext2,
                        CFG.imageURL_Ubuntu13_Large_ext2);
            }
            dialog.dismiss();
        }
    });

    Button btn_DownloadSmall = (Button) dialog.findViewById(R.id.btn_DownloadSmall);
    btn_DownloadSmall.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (AppPreferences.getPrefs().getString("ANDROID", "1").equals("4.3")) {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Small_ext4,
                        CFG.imageURL_Ubuntu13_Small_ext4);
            } else {
                downloadImage(v.getContext(), CFG.torrentURL_Ubuntu13_Small_ext2,
                        CFG.imageURL_Ubuntu13_Small_ext2);
            }
            dialog.dismiss();
        }
    });
    dialog.show();

}

From source file:com.kircherelectronics.gyroscopeexplorer.activity.GyroscopeActivity.java

private void showHelpDialog() {
    Dialog helpDialog = new Dialog(this);

    helpDialog.setCancelable(true);
    helpDialog.setCanceledOnTouchOutside(true);
    helpDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    View view = getLayoutInflater().inflate(R.layout.layout_help_home, null);

    helpDialog.setContentView(view);//  w  ww  . ja va  2 s  .  com

    helpDialog.show();
}

From source file:com.memetro.android.MainActivity.java

public void showRecoverPassDialog(final Context context) {

    final Dialog mDialog = new Dialog(context);
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mDialog.setContentView(R.layout.dialog_recover);
    mDialog.setCancelable(true);

    final EditText emailText = (EditText) mDialog.findViewById(R.id.email);
    Button sendButton = (Button) mDialog.findViewById(R.id.send);

    sendButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            RecoverPassUtils.recoverPass(context, emailText.getText().toString(), new OAuthHandler() {
                public void onStart() {
                    pdialog.show();// w  w w .ja  va 2s .  co  m
                }

                public void onSuccess() {
                    mDialog.dismiss();
                    MemetroDialog.showDialog(MainActivity.this, null, getString(R.string.recover_ok));
                }

                public void onFailure() {
                    MemetroDialog.showDialog(MainActivity.this, null, getString(R.string.recover_ko));
                }

                public void onFinish() {
                    pdialog.dismiss();
                }
            });
        }
    });

    mDialog.show();
}

From source file:com.zpwebsites.linuxonandroid.Install_Kali_2.java

private void downloadImage(Context context, final String torrentName, final String sourceforgeName) {
    if (torrentName.equals("")) {
        Intent localIntent = new Intent("android.intent.action.VIEW");
        localIntent.setData(Uri.parse(sourceforgeName));
        startActivity(localIntent);/*from www . j  a va2s .c  o  m*/
        return;
    }

    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_download_type_selector);
    // dialog.setTitle(R.string.dialog_select_donwload_type_title);
    dialog.setCancelable(true);

    Button btn_Torrent = (Button) dialog.findViewById(R.id.btn_Torrent);
    btn_Torrent.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent localIntent = new Intent("android.intent.action.VIEW");
            localIntent.setData(Uri.parse(torrentName));
            startActivity(localIntent);
            dialog.dismiss();
        }
    });

    Button btn_Sourceforge = (Button) dialog.findViewById(R.id.btn_Sourceforge);
    btn_Sourceforge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent localIntent = new Intent("android.intent.action.VIEW");
            localIntent.setData(Uri.parse(sourceforgeName));
            startActivity(localIntent);
            dialog.dismiss();
        }
    });

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

    dialog.show();
}

From source file:com.zpwebsites.linuxonandroid.opensource.Install_Backtrack_2.java

private void downloadImage(Context context, final String torrentName, final String sourceforgeName) {
    if (torrentName.equals("")) {
        Intent localIntent = new Intent("android.intent.action.VIEW");
        localIntent.setData(Uri.parse(sourceforgeName));
        startActivity(localIntent);/*from   w  w  w.j  av  a 2s .  com*/
        return;
    }

    final Dialog dialog = new Dialog(context);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_download_type_selector);
    //          dialog.setTitle(R.string.dialog_select_donwload_type_title);
    dialog.setCancelable(true);

    Button btn_Torrent = (Button) dialog.findViewById(R.id.btn_Torrent);
    btn_Torrent.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent localIntent = new Intent("android.intent.action.VIEW");
            localIntent.setData(Uri.parse(torrentName));
            startActivity(localIntent);
            dialog.dismiss();
        }
    });

    Button btn_Sourceforge = (Button) dialog.findViewById(R.id.btn_Sourceforge);
    btn_Sourceforge.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent localIntent = new Intent("android.intent.action.VIEW");
            localIntent.setData(Uri.parse(sourceforgeName));
            startActivity(localIntent);
            dialog.dismiss();
        }
    });

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

    dialog.show();
}

From source file:com.wrmndfzzy.atomize.intro.IntroActivity.java

protected void applicenseDialog() {
    final Dialog aLDialog = new Dialog(IntroActivity.this);
    aLDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    aLDialog.setTitle("License Agreement");
    aLDialog.setCancelable(false);
    aLDialog.setCanceledOnTouchOutside(false);
    aLDialog.setContentView(R.layout.app_license_dialog);
    WebView lic = (WebView) aLDialog.findViewById(R.id.atomizeLic);
    Button disagree = (Button) aLDialog.findViewById(R.id.alDialogDisagree);
    Button agree = (Button) aLDialog.findViewById(R.id.alDialogAgree);
    lic.getSettings().setUseWideViewPort(true);
    lic.loadUrl("file:///android_asset/atomizeLicense.html");
    disagree.setOnClickListener(new View.OnClickListener() {
        @Override// ww w.  j  a  v a2s  .  com
        public void onClick(View v) {
            aLDialog.dismiss();
            SharedPreferences.Editor e = getPrefs.edit();
            e.putBoolean("agreedToLicense", false);
            e.apply();
            Intent homeIntent = new Intent(Intent.ACTION_MAIN);
            homeIntent.addCategory(Intent.CATEGORY_HOME);
            homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(homeIntent);
            IntroActivity.this.finish();
            MainActivity.getInstance().finish();
        }
    });
    agree.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SharedPreferences.Editor e = getPrefs.edit();
            e.putBoolean("agreedToLicense", true);
            e.apply();
            aLDialog.dismiss();
        }
    });
    aLDialog.show();
}

From source file:com.infamous.site.activity.MainActivity.java

public Dialog getChangelog() {
    final Dialog CDialog = new Dialog(MainActivity.this);
    CDialog.setTitle(getResources().getString(R.string.changelog_title));
    CDialog.setContentView(R.layout.changelog);
    CDialog.setCanceledOnTouchOutside(true);
    CDialog.setCancelable(true);

    Button Close = (Button) CDialog.findViewById(R.id.close);
    Close.setOnClickListener(new View.OnClickListener() {
        @Override/*from  w w w .  j a  v a2 s. c  o m*/
        public void onClick(View v) {
            CDialog.dismiss();
        }
    });

    return CDialog;
}

From source file:de.domjos.schooltools.activities.LearningCardOverviewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.learning_card_overview_activity);
    this.initControls();

    this.cmdLearningCardQueryStart.setOnClickListener(new View.OnClickListener() {
        @Override/*from   w  ww  .  j  ava  2  s  .c om*/
        public void onClick(View v) {
            final LearningCardQueryTraining learningCardQueryTraining = new LearningCardQueryTraining();
            if (cmdLearningCardQueryStart.getText().equals(getString(R.string.learningCard_query))) {
                final Dialog dialog = new Dialog(LearningCardOverviewActivity.this);
                dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                dialog.setContentView(R.layout.learning_card_dialog);
                dialog.setCancelable(true);

                final Spinner spLearningCardQuery = dialog.findViewById(R.id.spLearningCardQueries);
                final ArrayAdapter<LearningCardQuery> learningCardQueries = new ArrayAdapter<>(
                        getApplicationContext(), android.R.layout.simple_spinner_item,
                        MainActivity.globals.getSqLite().getLearningCardQueries(""));
                spLearningCardQuery.setAdapter(learningCardQueries);
                learningCardQueries.notifyDataSetChanged();

                final Button btnStartSop = dialog.findViewById(R.id.cmdStart);
                btnStartSop.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        learningCardQueryTraining.setLearningCardQuery(
                                learningCardQueries.getItem(spLearningCardQuery.getSelectedItemPosition()));
                        learningCardQueryTraining.setID(MainActivity.globals.getSqLite()
                                .insertOrUpdateLearningCardQueryTraining(learningCardQueryTraining));
                        cmdLearningCardQueryStart.setText(getString(R.string.learningCard_query_end));
                        fragmentAdapter.setQuery(learningCardQueryTraining);
                        viewPager.setAdapter(fragmentAdapter);
                        dialog.dismiss();
                    }
                });
                dialog.show();
            } else {
                int wrongCards = 0, rightCards = 0, firstTry = 0, secondTry = 0, thirdTry = 0;
                LearningCardQueryTraining reloadedTraining = MainActivity.globals.getSqLite()
                        .getLearningCardQueryTraining("ID=" + learningCardQueryTraining.getID()).get(0);
                for (LearningCardQueryResult result : reloadedTraining.getResults()) {
                    if (result.isResult1() || result.isResult2() || result.isResult3()) {
                        rightCards++;
                        if (result.isResult1()) {
                            firstTry++;
                        } else if (result.isResult2()) {
                            secondTry++;
                        } else {
                            thirdTry++;
                        }
                    } else {
                        wrongCards++;
                    }
                }
                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                        LearningCardOverviewActivity.this);
                alertDialogBuilder.setTitle(R.string.learningCard_result);
                String content = String.format("%s %s%n%s %s%n%s %s%n%s %s%n%s %s%n",
                        getString(R.string.learningCard_result_right), rightCards,
                        getString(R.string.learningCard_result_wrong), wrongCards,
                        getString(R.string.learningCard_result_firstTry), firstTry,
                        getString(R.string.learningCard_result_secondTry), secondTry,
                        getString(R.string.learningCard_result_thirdTry), thirdTry);
                alertDialogBuilder.setMessage(content);
                alertDialogBuilder.create().show();

                cmdLearningCardQueryStart.setText(getString(R.string.learningCard_query));
                fragmentAdapter.setQuery(null);
                viewPager.setAdapter(fragmentAdapter);
            }
        }
    });
}