List of usage examples for android.app AlertDialog.Builder setCancelable
public void setCancelable(boolean flag)
From source file:gr.scify.newsum.ui.SearchViewActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_NORMAL & (getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_SMALL) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); }//from ww w . ja v a2s. co m SharedPreferences usertheme = getSharedPreferences("theme", 0); int newTheme = usertheme.getInt("theme", 2); Utils.onActivityCreateSetTheme(this, newTheme); SharedPreferences userlang = getSharedPreferences("lang", 0); String newlang = userlang.getString("lang", Locale.getDefault().getLanguage()); Setlanguage.updateLanguage(getApplicationContext(), newlang); GestureOverlayView gestureOverlayView = new GestureOverlayView(this); View inflate = getLayoutInflater().inflate(R.layout.view, null); gestureOverlayView.addView(inflate); gestureOverlayView.addOnGesturePerformedListener(this); gestureOverlayView.setGestureColor(Color.TRANSPARENT); gestureOverlayView.setUncertainGestureColor(Color.TRANSPARENT); gestureLib = GestureLibraries.fromRawResource(this, R.raw.gestures); if (!gestureLib.load()) { finish(); } requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(gestureOverlayView); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); ImageView title_image = (ImageView) findViewById(R.id.title_image); title_image.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(getResources().getString(R.string.scify))); startActivity(browse); } }); // setContentView(R.layout.view); // TODO: Add Loading dialog SharedPreferences setvmassage = getSharedPreferences("dialog", 0); boolean dialogShown = setvmassage.getBoolean("dialogShown", false); if (!dialogShown) { // prepare the alert box AlertDialog.Builder alertbox = new AlertDialog.Builder(this); alertbox.setMessage(R.string.view_massage); alertbox.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { } }); alertbox.setCancelable(false); alertbox.show(); SharedPreferences.Editor editor = setvmassage.edit(); editor.putBoolean("dialogShown", true); editor.commit(); } // Init waiting dialog showWaitingDialog(); initLayoutAndControls(); }
From source file:com.ranglerz.tlc.tlc.com.ranglerz.tlc.tlc.Insurance.AddDriver.java
public void serverNotResponding() { android.app.AlertDialog.Builder dialog = new android.app.AlertDialog.Builder(this); dialog.setCancelable(false); dialog.setTitle("Alert"); dialog.setMessage("Server not Responding"); dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override/*from w w w. j a va2s . c om*/ public void onClick(DialogInterface dialog, int id) { //Action for "Delete". } }).setNegativeButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Action for "Cancel". } }); final android.app.AlertDialog alert = dialog.create(); alert.show(); }
From source file:com.ranglerz.tlc.tlc.com.ranglerz.tlc.tlc.Insurance.AddDriver.java
public void dataSent() { android.app.AlertDialog.Builder dialog = new android.app.AlertDialog.Builder(this); dialog.setCancelable(false); dialog.setTitle("Alert"); dialog.setMessage("Data Sent Successfully"); dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override//from www . ja v a 2s .c o m public void onClick(DialogInterface dialog, int id) { Intent intent = new Intent(AddDriver.this, ThankYouScreen.class); startActivity(intent); } }).setNegativeButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Action for "Cancel". } }); final android.app.AlertDialog alert = dialog.create(); alert.show(); }
From source file:com.ranglerz.tlc.tlc.com.ranglerz.tlc.tlc.Insurance.AddDriver.java
public void dataNotSent() { android.app.AlertDialog.Builder dialog = new android.app.AlertDialog.Builder(this); dialog.setCancelable(false); dialog.setTitle("Alert"); dialog.setMessage("Data Not Sent"); dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override/*from w w w . j a v a 2s . c o m*/ public void onClick(DialogInterface dialog, int id) { //Action for "Delete". } }).setNegativeButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Action for "Cancel". } }); final android.app.AlertDialog alert = dialog.create(); alert.show(); }
From source file:com.andybotting.tramhunter.activity.HomeActivity.java
/** * Show the about dialog/* www . j ava 2 s . c om*/ */ public void showAbout() { // Get the package name String heading = getResources().getText(R.string.app_name).toString(); try { PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0); heading += " v" + pi.versionName + ""; } catch (NameNotFoundException e) { e.printStackTrace(); } // Build alert dialog, using a ContextThemeWrapper for proper theming AlertDialog.Builder dialogBuilder = new AlertDialog.Builder( new ContextThemeWrapper(this, R.style.AlertDialog)); View aboutView = View.inflate(new ContextThemeWrapper(this, R.style.AlertDialog), R.layout.dialog_about, null); dialogBuilder.setTitle(heading); dialogBuilder.setView(aboutView); dialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { mPreferenceHelper.setFirstLaunchThisVersion(); } }); dialogBuilder.setCancelable(false); dialogBuilder.setIcon(R.drawable.icon); dialogBuilder.show(); }
From source file:com.example.android.cardreader.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.alternate_main_fragment); //TODO Stop Executing Eden //Globals.executeEden(); getUsers(1);/*from www . java2s . c o m*/ instance = this; final ActionBar actionBar = getActionBar(); actionBar.setTitle(" TartanHacks"); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_bg)); actionBar.setStackedBackgroundDrawable(getResources().getDrawable(R.drawable.tab_bg)); actionBar.setDisplayShowHomeEnabled(true); frags.add(new PersonListFrag(Globals.pending)); frags.add(new PersonListFrag(Globals.allUsers)); frags.add(new PersonListFrag(Globals.checkedIn)); mAdapter = new FragmentAdapter(getFragmentManager()); fab = findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { View dialogView = View.inflate(instance, R.layout.dialog_signup, null); idField = (EditText) dialogView.findViewById(R.id.andrewIdField); pb = (ProgressBar) dialogView.findViewById(R.id.progress); nameField = (TextView) dialogView.findViewById(R.id.name); scanView = (TextView) dialogView.findViewById(R.id.scan_view); idField.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { String id = s.toString(); pb.setVisibility(View.VISIBLE); queryId(id); } @Override public void afterTextChanged(Editable s) { } }); AlertDialog.Builder builder; builder = new AlertDialog.Builder(instance); builder.setView(dialogView); builder.setCancelable(true); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { Globals.adding = false; } }); signupDialog = builder.show(); } }); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setOffscreenPageLimit(0); mViewPager.setAdapter(mAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); actionBar.addTab(actionBar.newTab().setText("Pending").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("All").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("Checked In").setTabListener(this)); mLoyaltyCardReader = new LoyaltyCardReader(this); // Disable Android Beam and register our card reader callback enableReaderMode(); new UpdateThread().executeOnExecutor(Executors.newSingleThreadExecutor()); }
From source file:com.linangran.tgfcapp.activities.MainActivity.java
public void showExitDialog(final String title, final String content, final boolean gotoMarket) { handler.post(new Runnable() { @Override//from w ww. j a va 2 s .com public void run() { if (MainActivity.this.registerDialog != null && MainActivity.this.registerDialog.isShowing()) { MainActivity.this.registerDialog.dismiss(); } AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle(title).setMessage(content).setPositiveButton(R.string.text_exit, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { MainActivity.this.finish(); if (gotoMarket) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("market://details?id=com.linangran.tgfcapp")); startActivity(intent); } } }); builder.setCancelable(false); builder.show(); } }); }
From source file:An.stop.AnstopActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog;/* ww w . j av a 2 s . c om*/ switch (id) { case ABOUT_DIALOG: AlertDialog.Builder aboutBuilder = new AlertDialog.Builder(this); aboutBuilder.setMessage(R.string.about_dialog).setCancelable(true).setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); dialog = aboutBuilder.create(); break; case SAVE_DIALOG: AlertDialog.Builder saveBuilder = new AlertDialog.Builder(this); saveBuilder.setTitle(R.string.save); saveBuilder.setMessage(R.string.save_dialog); final EditText input = new EditText(this); saveBuilder.setView(input); saveBuilder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // TODO save! Toast toast = Toast.makeText(getApplicationContext(), R.string.saved_succes, Toast.LENGTH_SHORT); toast.show(); } }); saveBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }); saveBuilder.setCancelable(false); dialog = saveBuilder.create(); break; default: dialog = null; } return dialog; }
From source file:com.doomonafireball.hackerswiperfree.android.activity.MainActivity.java
private void showOpenSourceDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.open_source_licenses); String[] apacheProjects = getResources().getStringArray(R.array.apache_licensed_projects); StringBuilder sb = new StringBuilder(); sb.append(getResources().getString(R.string.licenses_header)); for (String project : apacheProjects) { sb.append("\u2022 ").append(project).append("\n"); }//from w ww . ja va 2s . c om sb.append("\n").append(getResources().getString(R.string.licenses_subheader)); sb.append(getResources().getString(R.string.apache_2_0_license)); builder.setMessage(sb.toString()); builder.setPositiveButton(getString(R.string.close), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setCancelable(true); builder.setIcon(android.R.drawable.ic_menu_info_details); AlertDialog dialog = builder.create(); dialog.show(); }
From source file:com.owncloud.android.ui.activity.ReceiveExternalFilesActivity.java
/** * Show a dialog where the user can enter a filename for the file he wants to place the text in. *//* ww w. ja v a2s .co m*/ private void showUploadTextDialog() { final AlertDialog.Builder builder = new Builder(this); final View dialogView = getLayoutInflater().inflate(R.layout.dialog_upload_text, null); builder.setView(dialogView); builder.setTitle(R.string.uploader_upload_text_dialog_title); builder.setCancelable(false); builder.setPositiveButton(R.string.uploader_btn_upload_text, null); builder.setNegativeButton(android.R.string.cancel, null); final TextInputEditText input = dialogView.findViewById(R.id.inputFileName); final TextInputLayout inputLayout = dialogView.findViewById(R.id.inputTextLayout); input.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { inputLayout.setError(null); inputLayout.setErrorEnabled(false); } }); final AlertDialog alertDialog = builder.create(); setFileNameFromIntent(alertDialog, input); alertDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { Button button = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE); button.setOnClickListener(view -> { String fileName = input.getText().toString(); String error = null; if (fileName.length() > MAX_FILENAME_LENGTH) { error = String.format( getString(R.string.uploader_upload_text_dialog_filename_error_length_max), MAX_FILENAME_LENGTH); } else if (fileName.length() == 0) { error = getString(R.string.uploader_upload_text_dialog_filename_error_empty); } else { fileName += ".txt"; Uri fileUri = savePlainTextToFile(fileName); mStreamsToUpload.clear(); mStreamsToUpload.add(fileUri); uploadFiles(); } inputLayout.setErrorEnabled(error != null); inputLayout.setError(error); }); } }); alertDialog.show(); }