List of usage examples for android.app AlertDialog.Builder create
public void create()
From source file:com.njlabs.amrita.aid.gpms.ui.GpmsActivity.java
@Override public void init(Bundle savedInstanceState) { setupLayout(R.layout.activity_gpms_login, Color.parseColor("#009688")); rollNoEditText = (EditText) findViewById(R.id.roll_no); passwordEditText = (EditText) findViewById(R.id.pwd); AlertDialog.Builder builder = new AlertDialog.Builder(baseContext); builder.setMessage("Amrita University does not provide an API for accessing GPMS data. " + "So, if any changes are made to the GPMS Website, please be patient while I try to catch up.") .setCancelable(true).setIcon(R.drawable.ic_action_info_small) .setPositiveButton("Got it !", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel();/*w w w .ja v a 2s . co m*/ hideSoftKeyboard(); showConnectToAmritaAlert(); } }); AlertDialog alert = builder.create(); alert.requestWindowFeature(Window.FEATURE_NO_TITLE); alert.show(); dialog = new ProgressDialog(baseContext); dialog.setIndeterminate(true); dialog.setCancelable(false); dialog.setInverseBackgroundForced(false); dialog.setCanceledOnTouchOutside(false); dialog.setMessage("Authenticating your credentials ... "); preferences = getSharedPreferences("gpms_prefs", Context.MODE_PRIVATE); String rollNo = preferences.getString("roll_no", ""); String encodedPassword = preferences.getString("password", ""); if (!rollNo.equals("")) { rollNoEditText.setText(rollNo); studentRollNo = rollNo; hideSoftKeyboard(); } else { SharedPreferences aumsPrefs = getSharedPreferences("aums_prefs", Context.MODE_PRIVATE); String aumsRollNo = aumsPrefs.getString("RollNo", ""); if (!aumsRollNo.equals("")) { rollNoEditText.setText(aumsRollNo); studentRollNo = aumsRollNo; hideSoftKeyboard(); } } if (!encodedPassword.equals("")) { passwordEditText.setText(Security.decrypt(encodedPassword, MainApplication.key)); hideSoftKeyboard(); } }
From source file:truesculpt.ui.panels.WebFilePanel.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getManagers().getUtilsManager().updateFullscreenWindowStatus(getWindow()); setContentView(R.layout.webfile);// w w w . j a v a 2 s . co m getManagers().getUsageStatisticsManager().TrackEvent("OpenFromWeb", "", 1); mWebView = (WebView) findViewById(R.id.webview); mWebView.setWebViewClient(new MyWebViewClient()); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); mWebView.addJavascriptInterface(new JavaScriptInterface(this, getManagers()), "Android"); int nVersionCode = getManagers().getUpdateManager().getCurrentVersionCode(); mWebView.loadUrl(mStrBaseWebSite + "?version=" + nVersionCode); mPublishToWebBtn = (Button) findViewById(R.id.publish_to_web); mPublishToWebBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String name = getManagers().getMeshManager().getName(); final File imagefile = new File(getManagers().getFileManager().GetImageFileName()); final File objectfile = new File(getManagers().getFileManager().GetObjectFileName()); getManagers().getUsageStatisticsManager().TrackEvent("PublishToWeb", name, 1); if (imagefile.exists() && objectfile.exists()) { try { final File zippedObject = File.createTempFile("object", "zip"); zippedObject.deleteOnExit(); BufferedReader in = new BufferedReader(new FileReader(objectfile)); BufferedOutputStream out = new BufferedOutputStream( new GZIPOutputStream(new FileOutputStream(zippedObject))); System.out.println("Compressing file"); int c; while ((c = in.read()) != -1) { out.write(c); } in.close(); out.close(); long size = 0; size = new FileInputStream(imagefile).getChannel().size(); size += new FileInputStream(zippedObject).getChannel().size(); size /= 1000; final SpannableString msg = new SpannableString( "You will upload your latest saved version of this scupture representing " + size + " ko of data\n\n" + "When clicking the yes button you accept to publish your sculpture under the terms of the creative commons share alike, non commercial license\n" + "http://creativecommons.org/licenses/by-nc-sa/3.0" + "\n\nDo you want to proceed ?"); Linkify.addLinks(msg, Linkify.ALL); AlertDialog.Builder builder = new AlertDialog.Builder(WebFilePanel.this); builder.setMessage(msg).setCancelable(false) .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { PublishPicture(imagefile, zippedObject, name); } }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { } }); AlertDialog dlg = builder.create(); dlg.show(); // Make the textview clickable. Must be called after // show() ((TextView) dlg.findViewById(android.R.id.message)) .setMovementMethod(LinkMovementMethod.getInstance()); } catch (Exception e) { e.printStackTrace(); } } else { AlertDialog.Builder builder = new AlertDialog.Builder(WebFilePanel.this); builder.setMessage( "File has not been saved, you need to save it before publishing\nDo you want to proceed to save window ?") .setCancelable(false) .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { ((FileSelectorPanel) getParent()).getTabHost().setCurrentTab(2); } }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { } }); builder.show(); } } }); }
From source file:com.appfirst.activities.details.AFServerDetail.java
/** * Draw a view to display disk status./*from w w w .ja v a2 s . c om*/ * * @return a AlertDialog containing the view. */ @Override protected Dialog createDiskBusyDialog() { AlertDialog.Builder builder; AlertDialog alertDialog; builder = new AlertDialog.Builder(this); builder.setView(createDiskBusyListDialog()); builder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { removeDialog(DISK_BUSY_DIALOG); } }); if (MainHelper.isScreenVertical(this, WINDOW_SERVICE)) { builder.setMessage("Disk busy"); } alertDialog = builder.create(); alertDialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface arg0) { // TODO Auto-generated method stub currentDialogId = -1; } }); return alertDialog; }
From source file:com.dahl.brendan.wordsearch.view.WordSearchActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog;/*from w ww .j ava2 s.c o m*/ switch (id) { case DIALOG_ID_NO_WORDS: { final DialogNoWordsListener DIALOG_LISTENER_NO_WORDS = new DialogNoWordsListener(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.no_words); builder.setNegativeButton(R.string.category, DIALOG_LISTENER_NO_WORDS); builder.setPositiveButton(R.string.new_game, DIALOG_LISTENER_NO_WORDS); builder.setNeutralButton(R.string.size, DIALOG_LISTENER_NO_WORDS); dialog = builder.create(); break; } case DIALOG_ID_NO_WORDS_CUSTOM: { final DialogNoWordsCustomListener DIALOG_LISTENER_NO_WORDS_CUSTOM = new DialogNoWordsCustomListener(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.no_words_custom); builder.setNegativeButton(R.string.category, DIALOG_LISTENER_NO_WORDS_CUSTOM); builder.setPositiveButton(R.string.custom_editor, DIALOG_LISTENER_NO_WORDS_CUSTOM); dialog = builder.create(); break; } case DIALOG_ID_GAME_OVER: { final DialogGameOverListener DIALOG_LISTENER_GAME_OVER = new DialogGameOverListener(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("blank"); EditText text = new EditText(this); text.setSingleLine(); text.setId(android.R.id.input); builder.setView(text); builder.setPositiveButton(R.string.SAVE_SUBMIT, DIALOG_LISTENER_GAME_OVER); builder.setNeutralButton(R.string.SAVE, DIALOG_LISTENER_GAME_OVER); builder.setOnCancelListener(DIALOG_LISTENER_GAME_OVER); dialog = builder.create(); break; } case DIALOG_ID_HIGH_SCORES_LOCAL_SHOW: { final DialogHighScoresLocalShowListener DIALOG_LISTENER_HIGH_SCORES_SHOW = new DialogHighScoresLocalShowListener(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage("blank"); builder.setTitle(R.string.LOCAL_HIGH_SCORES); builder.setNegativeButton(R.string.reset, DIALOG_LISTENER_HIGH_SCORES_SHOW); builder.setNeutralButton(android.R.string.ok, DIALOG_LISTENER_HIGH_SCORES_SHOW); builder.setPositiveButton(R.string.GLOBAL, DIALOG_LISTENER_HIGH_SCORES_SHOW); dialog = builder.create(); break; } case DIALOG_ID_GAME_NEW: { final DialogGameNewListener DIALOG_LISTENER_GAME_NEW = new DialogGameNewListener(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(this.getString(R.string.game_over)); builder.setPositiveButton(R.string.new_game, DIALOG_LISTENER_GAME_NEW); builder.setNeutralButton(R.string.REPLAY, DIALOG_LISTENER_GAME_NEW); builder.setNegativeButton(android.R.string.cancel, DIALOG_LISTENER_GAME_NEW); dialog = builder.create(); break; } case DIALOG_ID_INTRO_INPUT_TYPE: { final DialogIntroListener DIALOG_LISTENER_INTRO = new DialogIntroListener(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.INTRO); builder.setPositiveButton(R.string.tap, DIALOG_LISTENER_INTRO); builder.setNeutralButton(android.R.string.cancel, DIALOG_LISTENER_INTRO); builder.setNegativeButton(R.string.drag, DIALOG_LISTENER_INTRO); dialog = builder.create(); break; } case DIALOG_ID_INTRO_DONATE: { final DialogInterface.OnClickListener LISTENER = new DialogIntroDonateListener(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.INTRO_DONATE_MSG); builder.setPositiveButton(R.string.DONATE, LISTENER); builder.setNegativeButton(R.string.DONATE_NO, LISTENER); dialog = builder.create(); break; } case DIALOG_ID_DONATE: { final DialogInterface.OnClickListener LISTENER = new DialogDonateListener(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.DONATE_MSG); builder.setPositiveButton(R.string.DONATE_MARKET, LISTENER); builder.setNeutralButton(R.string.DONATE_WEB, LISTENER); builder.setNegativeButton(R.string.DONATE_NO, LISTENER); dialog = builder.create(); break; } default: dialog = super.onCreateDialog(id); break; } return dialog; }
From source file:com.lovejoy777sarootool.rootool.dialogs.UnpackDialog.java
@Override public Dialog onCreateDialog(Bundle state) { final Activity a = getActivity(); // Set an EditText view to get user input final EditText inputf = new EditText(a); inputf.setHint(R.string.enter_name); inputf.setText(BrowserActivity.getCurrentlyDisplayedFragment().mCurrentPath + "/"); final AlertDialog.Builder b = new AlertDialog.Builder(a); b.setTitle(R.string.extractto);/*w ww. j a v a 2 s. co m*/ b.setView(inputf); b.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String newpath = inputf.getText().toString(); dialog.dismiss(); if (ext.equals("zip")) { final UnZipTask task = new UnZipTask(a); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath); } else if (ext.equals("rar")) { final UnRarTask task = new UnRarTask(a); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath); } } }); b.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); return b.create(); }
From source file:com.njlabs.amrita.aid.gpms.ui.GpmsActivity.java
public void openApply(View v) { final String[] items = { "Day Pass", "Home Pass" }; AlertDialog.Builder builder = new AlertDialog.Builder(baseContext); builder.setCancelable(true);//from ww w .j av a 2s. c o m builder.setTitle("Pass type ?"); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogList, int item) { Intent intent = new Intent(baseContext, PassApplyActivity.class); intent.putExtra("pass_type", items[item]); if (relays != null && relays.size() > 0 && identifier != null) { intent.putParcelableArrayListExtra("relays", relays); intent.putExtra("identifier", identifier); } startActivity(intent); } }); AlertDialog alertDialog = builder.create(); alertDialog.show(); }
From source file:com.dnielfe.manager.dialogs.UnpackDialog.java
@Override public Dialog onCreateDialog(Bundle state) { final Activity a = getActivity(); // Set an EditText view to get user input final EditText inputf = new EditText(a); inputf.setHint(R.string.enter_name); inputf.setText(Browser.mCurrentPath); final AlertDialog.Builder b = new AlertDialog.Builder(a); b.setTitle(R.string.extractto);/* ww w . j a v a2s .c o m*/ b.setView(inputf); b.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String newpath = inputf.getText().toString(); dialog.dismiss(); if (ext.equals("zip")) { final UnZipTask task = new UnZipTask(a); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath); } else if (ext.equals("rar")) { final UnRarTask task = new UnRarTask(a); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath); } } }); b.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); return b.create(); }
From source file:com.pentacog.mctracker.MCServerTrackerActivity.java
/** * Presents a dialog confirming server deletion * @param position index of server to delete *//*w w w . j a v a2 s. c o m*/ private void deleteServer(final int position) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.delete_caution); builder.setPositiveButton(R.string.yes, new OnClickListener() { @SuppressWarnings("unchecked") @Override public void onClick(DialogInterface dialog, int which) { serverList.remove(position); new SaveServerListTask(getApplicationContext()).execute(serverList.getServerList()); updateListView(); } }); builder.setNegativeButton(R.string.no, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); }
From source file:org.deviceconnect.android.manager.setting.ReqResDebugActivity.java
/** * ?.//from w w w.j a v a2 s . co m */ private void openErrorDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("?"); builder.setMessage("???????"); builder.create().show(); }
From source file:edu.mum.ml.group7.guessasketch.android.EasyPaint.java
@Override public boolean onOptionsItemSelected(MenuItem item) { mPaint.setXfermode(null);/*from w ww .j av a 2s . com*/ mPaint.setAlpha(0xFF); switch (item.getItemId()) { case R.id.normal_brush_menu: mPaint.setShader(null); mPaint.setMaskFilter(null); return true; case R.id.color_menu: new ColorPickerDialog(this, this, mPaint.getColor()).show(); return true; case R.id.size_menu: { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.brush, (ViewGroup) findViewById(R.id.root)); AlertDialog.Builder builder = new AlertDialog.Builder(this).setView(layout); builder.setTitle(R.string.choose_width); final AlertDialog alertDialog = builder.create(); alertDialog.show(); SeekBar sb = (SeekBar) layout.findViewById(R.id.brushSizeSeekBar); sb.setProgress(getStrokeSize()); final TextView txt = (TextView) layout.findViewById(R.id.sizeValueTextView); txt.setText( String.format(getResources().getString(R.string.your_selected_size_is), getStrokeSize() + 1)); sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(SeekBar seekBar, final int progress, boolean fromUser) { // Do something here with new value mPaint.setStrokeWidth(progress); txt.setText( String.format(getResources().getString(R.string.your_selected_size_is), progress + 1)); } @Override public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } @Override public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } }); return true; } case R.id.erase_menu: { LayoutInflater inflater_e = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout_e = inflater_e.inflate(R.layout.brush, (ViewGroup) findViewById(R.id.root)); AlertDialog.Builder builder_e = new AlertDialog.Builder(this).setView(layout_e); builder_e.setTitle(R.string.choose_width); final AlertDialog alertDialog_e = builder_e.create(); alertDialog_e.show(); SeekBar sb_e = (SeekBar) layout_e.findViewById(R.id.brushSizeSeekBar); sb_e.setProgress(getStrokeSize()); final TextView txt_e = (TextView) layout_e.findViewById(R.id.sizeValueTextView); txt_e.setText( String.format(getResources().getString(R.string.your_selected_size_is), getStrokeSize() + 1)); sb_e.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(SeekBar seekBar, final int progress, boolean fromUser) { // Do something here with new value mPaint.setStrokeWidth(progress); txt_e.setText( String.format(getResources().getString(R.string.your_selected_size_is), progress + 1)); } public void onStartTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } public void onStopTrackingTouch(SeekBar seekBar) { // TODO Auto-generated method stub } }); mPaint.setShader(null); mPaint.setXfermode(new PorterDuffXfermode(Mode.CLEAR)); return true; } case R.id.clear_all_menu: { contentView.mBitmap.eraseColor(Color.TRANSPARENT); if (predictions != null) { resetPredictionsView(predictions, true); } return true; } case R.id.save_menu: sendScreenshot(false, ApiCallType.GUESS_IMAGE, ""); break; case R.id.about_menu: startActivity(new Intent(this, AboutActivity.class)); break; } return super.onOptionsItemSelected(item); }