本文整理匯總了Java中android.support.v7.app.AlertDialog.setCanceledOnTouchOutside方法的典型用法代碼示例。如果您正苦於以下問題:Java AlertDialog.setCanceledOnTouchOutside方法的具體用法?Java AlertDialog.setCanceledOnTouchOutside怎麽用?Java AlertDialog.setCanceledOnTouchOutside使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.app.AlertDialog
的用法示例。
在下文中一共展示了AlertDialog.setCanceledOnTouchOutside方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
@Override
protected void init(Bundle savedInstanceState) {
super.init(savedInstanceState);
final AlertDialog dialog = new AlertDialog.Builder(this)
.setTitle(R.string.crash_dialog_title)
.setView(R.layout.crash_report_dialog)
.setPositiveButton(R.string.ok, this)
.setNegativeButton(R.string.cancel, this)
.create();
dialog.setCanceledOnTouchOutside(false);
dialog.setOnDismissListener(this);
dialog.show();
comment = (EditText) dialog.findViewById(android.R.id.input);
if (savedInstanceState != null) {
comment.setText(savedInstanceState.getString(STATE_COMMENT));
}
}
示例2: onCreateDialog
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
ViewGroup viewGroup = (ViewGroup) getActivity().getLayoutInflater()
.inflate(R.layout.dialog_key, null);
etUser = (EditText) viewGroup.findViewById(R.id.et_user);
AlertDialog alertDialog = new AlertDialog.Builder(getContext())
.setTitle(R.string.dlg_title_set_key)
.setView(viewGroup)
.setPositiveButton(R.string.dlg_bt_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
if (onContinueListener != null) {
onContinueListener.onContinue(etUser.getText().toString().trim());
}
}
})
.create();
alertDialog.setCanceledOnTouchOutside(false);
return alertDialog;
}
示例3: showResultDialog
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
private void showResultDialog(final String message, int code) {
try {
final AlertDialog dialog = new AlertDialog.Builder(this)
.setTitle(getString(com.mobillium.paparasdk.R.string.title))
.setMessage(message + " (" + code + ")")
.setPositiveButton(getString(R.string.done), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
})
.create();
dialog.setCanceledOnTouchOutside(false);
dialog.show();
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例4: openConfirmDialog
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
/**
* 彈出一個帶確認和取消的dialog
* @param context
* @param title
* @param msg
* @param okbutton
* @param ok 點擊確定事件
* @param nobutton
* @param no 點擊取消事件
* @return
*/
public static AlertDialog openConfirmDialog(Context context, String title,
String msg, String okbutton, DialogInterface.OnClickListener ok, String nobutton,
DialogInterface.OnClickListener no) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title);
builder.setMessage("\n" + msg + "\n");
builder.setNegativeButton(okbutton, ok);
builder.setNeutralButton(nobutton, no);
AlertDialog loadWaitDialog = builder.create();
loadWaitDialog.setCanceledOnTouchOutside(false);
loadWaitDialog.show();
return loadWaitDialog;
}
示例5: onInitialized
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
@Override
public void onInitialized(MainPresenter presenter, MainViewState viewState) {
if (!presenter.isInitialized()) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.enter_key);
builder.setMessage(R.string.key_requirments_message);
EditText editText = new EditText(this);
editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(16)});
builder.setView(editText);
builder.setPositiveButton(R.string.apply, null);
AlertDialog dialog = builder.create();
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false);
dialog.show();
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(v -> {
if (editText.getText().length() == 16) {
String key = editText.getText().toString();
presenter.initializeWithKey(key);
presenter.getValues();
dialog.dismiss();
} else {
Toast.makeText(this, R.string.bad_key, Toast.LENGTH_LONG).show();
}
});
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) editText.getLayoutParams();
int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16f, getResources().getDisplayMetrics());
layoutParams.setMargins(margin, margin, margin, margin);
editText.requestLayout();
} else {
if (!viewState.isPrefsLoaded() && !presenter.isTaskRunning(MainPresenter.TASK_GET_RUNNING)) {
presenter.getValues();
}
}
}
示例6: requestPermissions
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
public static void requestPermissions(
final Activity activity,
int title,
int message,
final int requestCode,
final String... permissions)
{
boolean shouldShowDialog = false;
for (String permission : permissions) {
if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
shouldShowDialog = true;
break;
}
}
if (shouldShowDialog) {
AlertDialog builder = new AlertDialog.Builder(activity).setTitle(title)
.setMessage(message)
.setPositiveButton(android.R.string.ok, null)
.create();
builder.setCanceledOnTouchOutside(false);
builder.show();
builder.setOnDismissListener(new DialogInterface.OnDismissListener()
{
@Override
public void onDismiss(DialogInterface dialog)
{
ActivityCompat.requestPermissions(activity, permissions, requestCode);
}
});
} else {
ActivityCompat.requestPermissions(activity, permissions, requestCode);
}
}
示例7: onCreateDialog
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
super.onCreateDialog(savedInstanceState);
LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.other_forms_of_history_dialog, null);
// Linkify the <link></link> span in the dialog text.
TextView textView = (TextView) view.findViewById(R.id.text);
final SpannableString textWithLink = SpanApplier.applySpans(
textView.getText().toString(),
new SpanApplier.SpanInfo("<link>", "</link>", new NoUnderlineClickableSpan() {
@Override
public void onClick(View widget) {
new TabDelegate(false /* incognito */).launchUrl(
WEB_HISTORY_URL, TabLaunchType.FROM_CHROME_UI);
}
}));
textView.setText(textWithLink);
textView.setMovementMethod(LinkMovementMethod.getInstance());
// Construct the dialog.
AlertDialog dialog = new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
.setView(view)
.setTitle(R.string.clear_browsing_data_history_dialog_title)
.setPositiveButton(
R.string.ok_got_it, this)
.create();
dialog.setCanceledOnTouchOutside(false);
return dialog;
}
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:33,代碼來源:OtherFormsOfHistoryDialogFragment.java
示例8: onPrompt
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
@Override
public void onPrompt(UpdateAgent agent) {
final UpdateInfo info = agent.getInfo();
String size = Formatter.formatShortFileSize(mContext, info.size);
String content = String.format("最新版本:%1$s\n新版本大小:%2$s\n\n更新內容\n%3$s", info.versionName, size, info.updateContent);
final AlertDialog dialog = new AlertDialog.Builder(mContext).create();
dialog.setTitle("應用更新");
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false);
float density = mContext.getResources().getDisplayMetrics().density;
TextView tv = new TextView(mContext);
tv.setMovementMethod(new ScrollingMovementMethod());
tv.setVerticalScrollBarEnabled(true);
tv.setTextSize(14);
tv.setMaxHeight((int) (250 * density));
dialog.setView(tv, (int) (25 * density), (int) (15 * density), (int) (25 * density), 0);
DialogInterface.OnClickListener listener = new OnPromptClick(agent, true);
if (info.isForce) {
tv.setText("您需要更新應用才能繼續使用\n\n" + content);
dialog.setButton(DialogInterface.BUTTON_POSITIVE, "確定", listener);
} else {
tv.setText(content);
dialog.setButton(DialogInterface.BUTTON_POSITIVE, "立即更新", listener);
dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "以後再說", listener);
if (info.isIgnorable) {
dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "忽略該版", listener);
}
}
dialog.show();
}
示例9: prompt
import android.support.v7.app.AlertDialog; //導入方法依賴的package包/類
@Override
public void prompt(IUpdateAgent agent) {
if (mContext instanceof Activity && ((Activity) mContext).isFinishing()) {
return;
}
final UpdateInfo info = agent.getInfo();
String size = Formatter.formatShortFileSize(mContext, info.size);
String content = String.format("最新版本:%1$s\n新版本大小:%2$s\n\n更新內容\n%3$s", info.versionName, size, info.updateContent);
final AlertDialog dialog = new AlertDialog.Builder(mContext).create();
dialog.setTitle("應用更新");
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false);
float density = mContext.getResources().getDisplayMetrics().density;
TextView tv = new TextView(mContext);
tv.setMovementMethod(new ScrollingMovementMethod());
tv.setVerticalScrollBarEnabled(true);
tv.setTextSize(14);
tv.setMaxHeight((int) (250 * density));
dialog.setView(tv, (int) (25 * density), (int) (15 * density), (int) (25 * density), 0);
DialogInterface.OnClickListener listener = new DefaultPromptClickListener(agent, true);
if (info.isForce) {
tv.setText("您需要更新應用才能繼續使用\n\n" + content);
dialog.setButton(DialogInterface.BUTTON_POSITIVE, "確定", listener);
} else {
tv.setText(content);
dialog.setButton(DialogInterface.BUTTON_POSITIVE, "立即更新", listener);
dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "以後再說", listener);
if (info.isIgnorable) {
dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "忽略該版", listener);
}
}
dialog.show();
}