Android AlertDialog - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android AlertDialog class.

This code example shows how to use the following methods:setButton, setMessage, setTitle, dismiss, isShowing
            dialog = new AlertDialog.Builder(context)
                    .setPositiveButton(android.R.string.ok, disconnectListener)
                    .setNegativeButton(android.R.string.cancel, null)
                    .create();
        } else { 
            if (dialog.isShowing()) {
                dialog.dismiss();
            } 
            // use disconnectListener for the correct profile(s) 
            CharSequence okText = context.getText(android.R.string.ok);
            dialog.setButton(DialogInterface.BUTTON_POSITIVE,
                    okText, disconnectListener);
        } 
        dialog.setTitle(title);
        dialog.setMessage(message);
        dialog.show();
        return dialog;
    } 
 
    // TODO: wire this up to show connection errors... 
    static void showConnectingError(Context context, String name) {
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setTitle, setCancelable, setOnCancelListener, show, setIndeterminate
This code example shows how to use the following methods:setTitle, setIndeterminate
    @Override 
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Bundle args = getArguments();
        String title = args.getString(ARG_TITLE);
 
        ProgressDialog dialog = new ProgressDialog(getActivity());
        dialog.setIndeterminate(true);
        dialog.setTitle(title);
 
        return dialog;
    } 
} 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setTitle, setCancelable, setIndeterminate, setMessage
 
    @Override 
    protected Dialog onCreateDialog(int id) {
        switch (id) {
            case DIALOG1_KEY: {
                ProgressDialog dialog = new ProgressDialog(this);
                dialog.setTitle("Indeterminate");
                dialog.setMessage("Please wait while loading...");
                dialog.setIndeterminate(true);
                dialog.setCancelable(true);
                return dialog;
            } 
            case DIALOG2_KEY: {
                ProgressDialog dialog = new ProgressDialog(this);
                dialog.setMessage("Please wait while loading...");
                dialog.setIndeterminate(true);
                dialog.setCancelable(true);
                return dialog;
            } 
        } 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getWindow, setCancelable, setCanceledOnTouchOutside, show
    public void showOptionDialogInternal(AlertDialog dialog) {
        final IBinder windowToken = KeyboardSwitcher.getInstance().getKeyboardView()
                .getWindowToken(); 
        if (windowToken == null) return;
 
        dialog.setCancelable(true);
        dialog.setCanceledOnTouchOutside(true);
 
        final Window window = dialog.getWindow();
        final WindowManager.LayoutParams lp = window.getAttributes();
        lp.token = windowToken;
        lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG;
        window.setAttributes(lp);
        window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
 
        mOptionsDialog = dialog;
        dialog.show();
    } 
 
    @Override 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setTitle, setCancelable, setOnCancelListener, show, setIndeterminate
	// show the progress bar. 
	public static ProgressDialog showProgress(Context context,
			CharSequence title, CharSequence message, boolean indeterminate,
			boolean cancelable)
	{ 
		ProgressDialog dialog = new ProgressDialog(context);
		dialog.setTitle(title);
		dialog.setMessage(message);
		dialog.setIndeterminate(indeterminate);
		dialog.setCancelable(false);
		//dialog.setDefaultButton(false); 
		dialog.setOnCancelListener( new AlixPay.AlixOnCancelListener( (Activity)context ) );
 
		dialog.show();
		return dialog;
	} 
	 
	public static JSONObject string2JSON(String str, String split)
	{ 
		JSONObject json = new JSONObject();
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setTitle, setCancelable, setIndeterminate, setMessage
	} 
 
	@Override 
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		setRetainInstance(true); 
		final ProgressDialog dialog = new ProgressDialog(getActivity());
		dialog.setTitle(mTitle);
		dialog.setMessage(mMessage);
		dialog.setIndeterminate(true);
		dialog.setCancelable(false);
 
		return dialog;
	} 
} 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setButton, setTitle, show, setProgressStyle
		noticeDialog = builder.create();
		noticeDialog.show();
	} 
	 
	private static void showDownloadDialog(Context context) {
		  progressDialog   =  new ProgressDialog(context);
		  progressDialog.setTitle("Update software");
		  
		  progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
	progressDialog.setButton("Cancel", new OnClickListener() {
		 
		@Override 
		public void onClick(DialogInterface dialog, int which) {
 
			 dialog.dismiss();
			 interceptFlag = true;
			  
		} 
	}); 
	progressDialog.show();

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setTitle, setCancelable, show
			this.cv.put(this.getKey(), this.v.getTimeInMillis());
			if (this.ul != null) {
				this.ul.onUpdateValue(this);
			} 
			if (this.dt) {
				TimePickerDialog tpd = new TimePickerDialog(this.getContext(), this,
						this.v.get(Calendar.HOUR_OF_DAY), this.v.get(Calendar.MINUTE), true);
				tpd.setTitle(this.getTitle());
				tpd.setCancelable(true);
				tpd.show();
			} 
		} 
	} 
 
	@Override 
	public void onTimeSet(final TimePicker view, final int hourOfDay, final int minute) {
		this.v.set(Calendar.HOUR_OF_DAY, hourOfDay);
		this.v.set(Calendar.MINUTE, minute);
		this.cv.put(this.getKey(), this.v.getTimeInMillis());
		if (this.ul != null) {
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setTitle, setCancelable, setOnCancelListener, show, setIndeterminate

Related Android AlertDialog Questions & Answers:

Other Android AlertDialog Examples

0:	AlertDialog alertDialog = new AlertDialog.Builder(
1:							AlertDialogActivity.this).create();
2:

Read More

7:				// device doesn't support flash
8:				// Show alert message and close the application
9:				AlertDialog alert = new AlertDialog.Builder(MainActivity.this)
10:						.create();
11:				alert.setTitle("Error");

Read More

17:		public void showAlertDialog(Context context, String title, String message,
18:				Boolean status) {
19:			AlertDialog alertDialog = new AlertDialog.Builder(context).create();
20:	
21:			// Setting Dialog Title

Read More

See Code Examples for Android AlertDialog Methods: