Java Code Examples for android.app.AlertDialog#setTitle()

The following examples show how to use android.app.AlertDialog#setTitle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AlertDialogManager.java    From odm with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Function to display simple Alert Dialog
 * 
 * @param context
 *            - application context
 * @param title
 *            - alert dialog title
 * @param message
 *            - alert message
 * @param status
 *            - success/failure (used to set icon) - pass null if you don't
 *            want icon
 * */
@SuppressWarnings("deprecation")
public void showAlertDialog(Context context, String title, String message, Boolean status) {
	AlertDialog alertDialog = new AlertDialog.Builder(context).create();
	// Setting Dialog Title
	alertDialog.setTitle(title);
	// Setting Dialog Message
	alertDialog.setMessage(message);
	if (status != null)
		// Setting alert dialog icon
		alertDialog.setIcon((status) ? R.drawable.success : R.drawable.fail);
	// Setting OK Button
	alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
		@Override
		public void onClick(DialogInterface dialog, int which) {
		}
	});
	// Showing Alert Message
	alertDialog.show();
}
 
Example 2
Source File: BlurNavigationDrawerActivity.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.about) {
        AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle(getString(R.string.app_name));
        alertDialog.setIcon(android.R.drawable.ic_dialog_info);
        alertDialog.setMessage("Developed by Basilis Charalampakis\n\n" +
                "GitHub     : http://github.com/charbgr\n" +
                "Linkedin  : http://linkedin.com/in/charalampakisbasilis/");
        alertDialog.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 3
Source File: SettingActivity.java    From RelaxFinger with GNU General Public License v2.0 6 votes vote down vote up
public void questionsAnswer() {

        AlertDialog dialog = new AlertDialog.Builder(this).create();
        dialog.setTitle("帮助说明");
        dialog.setCancelable(true);
        dialog.setCanceledOnTouchOutside(true);
        dialog.setMessage("1.不能卸载软件:在设置界面关闭“开启锁屏”选项后,即可正常卸载。\r\n" +
                "2.屏幕截图没反应:部分手机在第一次屏幕截图时需要稍等片刻,弹出授权框后,点击允许即可。\r\n" +
                "3.截图保存在哪里:截图保存在系统存储卡根目录RelaxFinger文件夹里面。\r\n" +
                "4.避让软键盘无效:安卓7.0以下系统避让软键盘功能最好安装两个及以上输入法(包含系统自带输入法)。\r\n" +
                "5.不能开机自启动:首先确保设置界面“开机启动”选项已开启,如果仍然不能启动,到系统设置->" +
                "安全->应用程序许可中找到RelaxFinger,点击进去后打开自动运行开关即可。\r\n" +
                "6.自定义主题不好看:在系统存储卡根目录找到RelaxFinger目录,将里面的DIY.png换成喜欢的图片" +
                ",确保新图片名称依然是DIY.png即可。\r\n" +
                "7.若频繁需要重新激活,系统设置->安全->应用程序许可->RelaxFinger->启用自动运行," +
                "部分国产手机->电池管理->受保护应用->启用悬浮助手,任务管理器中的一键清除也会杀掉悬浮助手," +
                "可以在任务管理界面,给悬浮助手加上锁即可,手机不同加锁方法自行百度," +
                "华为是任务管理器界面按住悬浮助手往下拉,MIUI好像是就有个锁,点一下就好了。\r\n" +
                "8.临时移动模式:悬浮球会向上移动一段距离,可自由移动,点击退出临时移动模式。打开关闭输入法会自动"+
                "进入和退出临时移动模式。\r\n"+
                "9.显示消息通知:当接收到消息时,悬浮球会变成相应的APP图标,并晃动提示,点击打开消息,上滑忽略"+
                "当前消息,下滑忽略所有消息。\r\n"+
                "10.安卓6.0及以上系统出现叠加层解决方法:在系统设置->开发者选项->停用HW叠加层即可。");
        dialog.show();
    }
 
Example 4
Source File: ScheduledDownloadsDialog.java    From aptoide-client with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
    final AlertDialog scheduleDownloadDialog = dialogBuilder.create();
    scheduleDownloadDialog.setTitle(getText(R.string.schDwnBtn));
    scheduleDownloadDialog.setIcon(android.R.drawable.ic_dialog_alert);
    scheduleDownloadDialog.setCancelable(false);
    scheduleDownloadDialog.setMessage(getText(R.string.schDown_install));
    scheduleDownloadDialog.setButton(Dialog.BUTTON_POSITIVE, getString(android.R.string.yes), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            if (callback!=null) callback.onOkClick();
        }
    });
    scheduleDownloadDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.no), new Dialog.OnClickListener() {
        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            if (callback!=null) callback.onCancelClick();
        }
    });


    return scheduleDownloadDialog;
}
 
Example 5
Source File: Notifier.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
public static void oneButtonAlert(Activity activity,String message, String title, String buttonText, final Runnable callBack) {
  Log.i(LOG_TAG, "One button alert " + message);
  AlertDialog alertDialog = new AlertDialog.Builder(activity).create();
  alertDialog.setTitle(title);
  // prevents the user from escaping the dialog by hitting the Back button
  alertDialog.setCancelable(false);
  alertDialog.setMessage(stringToHTML(message));
  alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL,
      buttonText, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
      if (callBack != null) {
        callBack.run();
      }
    }});
  alertDialog.show();
}
 
Example 6
Source File: AddTask.java    From endpoints-codelab-android with GNU General Public License v3.0 6 votes vote down vote up
private void showProjectContextMenu() {
	AlertDialog.Builder builder = new AlertDialog.Builder(this);
	final ArrayList<String> labels = new ArrayList<String>();
	labels.addAll(labelsInTaskbagAndText());

	if (labels.size() == 0) {
		onHelpClick();
		return;
	}

	builder.setItems(labels.toArray(new String[0]), new OnClickListener() {
		@Override
		public void onClick(DialogInterface arg0, int which) {
			replaceTextAtSelection(labels.get(which) + " ");
		}
	});

	// Create the AlertDialog
	AlertDialog dialog = builder.create();
	dialog.setTitle(R.string.addcontextproject);
	dialog.show();
}
 
Example 7
Source File: CommonGUI.java    From microbit with Apache License 2.0 6 votes vote down vote up
public static void commonAlertDialog(Context parent, String title, String message) {

        AlertDialog alertDialog = new AlertDialog.Builder(parent, AlertDialog.THEME_HOLO_DARK).create();
        alertDialog.setTitle(title);

        alertDialog.setMessage(Html.fromHtml(message));
        alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }
        );

        alertDialog.show();
    }
 
Example 8
Source File: Dialogs.java    From EFRConnect-android with Apache License 2.0 6 votes vote down vote up
public static Dialog showAlert(CharSequence title, CharSequence message, Context context,
                               CharSequence positiveBtnText, CharSequence negativeBtnText, OnClickListener positiveListener,
                               OnClickListener negativeListener) {

    final AlertDialog alert = new AlertDialog.Builder(context).create();
    alert.setCancelable(false);
    alert.setCanceledOnTouchOutside(false);
    if (positiveListener != null && positiveBtnText != null) {
        alert.setButton(AlertDialog.BUTTON_POSITIVE, positiveBtnText, positiveListener);
    }
    if (negativeListener != null && negativeBtnText != null) {
        alert.setButton(AlertDialog.BUTTON_NEGATIVE, negativeBtnText, negativeListener);
    }
    alert.setTitle(title);
    alert.setMessage(message);
    alert.show();
    return alert;
}
 
Example 9
Source File: PermissionHelper.java    From justaline-android with Apache License 2.0 6 votes vote down vote up
/**
 * Show dialog with rationale for required permissions
 *
 * @param activity calling activity which the AlertDialog is shown on (PermissionsActivity)
 * @return the dialog that is shown
 */
private static AlertDialog showRequiredPermissionRationale(final Activity activity) {
    final AlertDialog
            alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle(activity.getString(R.string.title_activity_permissions));
    alertDialog.setMessage(activity.getString(R.string.initial_permissions_required));

    alertDialog.setButton(android.support.v7.app.AlertDialog.BUTTON_NEUTRAL,
            activity.getString(R.string.ask_me_again),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    requestRequiredPermissions(activity, true);
                }
            });

    alertDialog.setCancelable(false);
    alertDialog.show();

    return alertDialog;
}
 
Example 10
Source File: MainActivity.java    From BotLibre with Eclipse Public License 1.0 5 votes vote down vote up
public static void confirm(String message, Activity activity, Boolean cancelable, DialogInterface.OnClickListener listener) {
	AlertDialog dialog = new AlertDialog.Builder(activity).create();
	dialog.setTitle(activity.getString(R.string.title));
	dialog.setMessage(message);
	dialog.setButton(AlertDialog.BUTTON_POSITIVE, "Yes", listener);
	dialog.setButton(AlertDialog.BUTTON_NEGATIVE, "NO", listener);
	if(cancelable){dialog.setButton(AlertDialog.BUTTON_NEUTRAL, "Cancel",listener);}
	dialog.show();
}
 
Example 11
Source File: AlertDialogManager.java    From restaurant-bot with GNU General Public License v3.0 5 votes vote down vote up
public void showAlertDialog(Context context, String title, String message,
                            Boolean status) {
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);
    alertDialog.setMessage(message);
    if(status != null)
        alertDialog.setIcon((status) ? R.drawable.success : R.drawable.fail);
    alertDialog.setButton("Тийм", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    alertDialog.show();
}
 
Example 12
Source File: CommonUtil.java    From dcs-sdk-java with Apache License 2.0 5 votes vote down vote up
/**
 * 展示一个通用的弹出框UI
 *
 * @param context 展示弹出框的上下文环境
 * @param title   警告的title信息
 * @param text    警告信息
 */
public static void showAlert(Context context, String title, String text) {
    AlertDialog alertDialog = new Builder(context).create();
    alertDialog.setTitle(title);
    alertDialog.setMessage(text);
    alertDialog.setCanceledOnTouchOutside(true);
    alertDialog.show();
}
 
Example 13
Source File: MessageFragment.java    From restcomm-android-sdk with GNU Affero General Public License v3.0 5 votes vote down vote up
private void showOkAlert(final String title, final String detail)
{
   AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
   alertDialog.setTitle(title);
   alertDialog.setMessage(detail);
   alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK", new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int which)
      {
         dialog.dismiss();
      }
   });
   alertDialog.show();
}
 
Example 14
Source File: ManagePatchesActivity.java    From MCPELauncher with Apache License 2.0 5 votes vote down vote up
public void preparePatchInfo(AlertDialog dialog, ContentListItem patch) {
	dialog.setTitle(patch.toString(getResources()));
	String patchInfo;
	try {
		patchInfo = getPatchInfo(patch);
	} catch (Exception e) {
		patchInfo = "Cannot show info: " + e.getStackTrace();
	}
	dialog.setMessage(patchInfo);
}
 
Example 15
Source File: MainActivity.java    From android-kubernetes-blockchain with Apache License 2.0 5 votes vote down vote up
public void saveUser(String result) {
    ResultOfEnroll resultOfEnroll = gson.fromJson(result, ResultOfEnroll.class);
    Log.d(TAG, resultOfEnroll.result.user);


    editor = sharedPreferences.edit();

    editor.putString("BlockchainUserId",resultOfEnroll.result.user);
    editor.apply();

    sendToMongo(resultOfEnroll.result.user);

    // send user id to registeree-api

    // save the user name

    AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
    alertDialog.setTitle("Enrollment successful!");
    alertDialog.setMessage("You have been enrolled to the blockchain network. Your User ID is:\n\n" + resultOfEnroll.result.user);
    alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "CONFIRM",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}
 
Example 16
Source File: PdfActivity.java    From Reader with Apache License 2.0 5 votes vote down vote up
@Override
public void showOpenErrorDialog(String reason) {
    Resources res = getResources();
    mAlertBuilder = new AlertDialog.Builder(this);
    AlertDialog alert = mAlertBuilder.create();
    alert.setCancelable(false);
    alert.setTitle(String.format(res.getString(R.string.cannot_open_document_Reason), reason));
    alert.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.dismiss),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    finish();
                }
            });
    alert.show();
}
 
Example 17
Source File: SettingActivity.java    From RelaxFinger with GNU General Public License v2.0 5 votes vote down vote up
public void developerInfo() {

        AlertDialog dialog = new AlertDialog.Builder(this).create();
        dialog.setTitle("关于悬浮助手");
        dialog.setCancelable(true);
        dialog.setCanceledOnTouchOutside(true);
        dialog.setMessage("版本:3.0.4.3\r\n作者:fg607\r\n邮箱:[email protected]");
        dialog.show();
    }
 
Example 18
Source File: Client.java    From apigee-android-sdk with Apache License 2.0 5 votes vote down vote up
public static void showAlert(Context context, String alertTitle, String alertMessage) {
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(alertTitle);
    alertDialog.setMessage(alertMessage);
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
        }
    });
    alertDialog.show();
}
 
Example 19
Source File: ManageScriptsActivity.java    From MCPELauncher with Apache License 2.0 5 votes vote down vote up
public void onPrepareDialog(int dialogId, Dialog dialog) {
	switch (dialogId) {
		case DIALOG_MANAGE_PATCH:
		case DIALOG_MANAGE_PATCH_CURRENTLY_ENABLED:
		case DIALOG_MANAGE_PATCH_CURRENTLY_DISABLED:
			if (selectedPatchItem == null) {
				break;
			}
			AlertDialog aDialog = (AlertDialog) dialog;
			aDialog.setTitle(selectedPatchItem.toString(getResources()));
			break;
		case DIALOG_PATCH_INFO:
			if (selectedPatchItem == null) {
				break;
			}
			preparePatchInfo((AlertDialog) dialog, selectedPatchItem);
			break;
		case DIALOG_IMPORT_FROM_CLIPBOARD_CODE:
			AlertDialog bDialog = (AlertDialog) dialog;
			android.text.ClipboardManager cmgr = (android.text.ClipboardManager) this.getSystemService(Context.CLIPBOARD_SERVICE);
			CharSequence cSequence = cmgr.getText();
			((EditText) bDialog.findViewById(20130805)).setText(cSequence);
			break;
		case DIALOG_IMPORT_FROM_INTENT:
			AlertDialog cDialog = (AlertDialog) dialog;
			cDialog.setTitle(getIntent().getData().toString());
			break;
		default:
			super.onPrepareDialog(dialogId, dialog);
	}
}
 
Example 20
Source File: MuPDFPageView.java    From mupdf-android with GNU Affero General Public License v3.0 4 votes vote down vote up
private void warnNoSignatureSupport() {
	AlertDialog dialog = mSignatureReportBuilder.create();
	dialog.setTitle("App built with no signature support");
	dialog.show();
}