當前位置: 首頁>>代碼示例>>Java>>正文


Java AlertDialog.setCanceledOnTouchOutside方法代碼示例

本文整理匯總了Java中android.app.AlertDialog.setCanceledOnTouchOutside方法的典型用法代碼示例。如果您正苦於以下問題:Java AlertDialog.setCanceledOnTouchOutside方法的具體用法?Java AlertDialog.setCanceledOnTouchOutside怎麽用?Java AlertDialog.setCanceledOnTouchOutside使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.AlertDialog的用法示例。


在下文中一共展示了AlertDialog.setCanceledOnTouchOutside方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: showAlert

import android.app.AlertDialog; //導入方法依賴的package包/類
/**
 * 展示一個通用的彈出框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();
}
 
開發者ID:dueros,項目名稱:dcs-sdk-java,代碼行數:15,代碼來源:CommonUtil.java

示例2: timeOut

import android.app.AlertDialog; //導入方法依賴的package包/類
public void timeOut(int team)
{
    currentTimeOutTeam = team;

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle("Timeout "+game.teams[team].getNotNullName());
    builder.setMessage("Pressing the play button uses the timeout of the team. This cannot be undone.");

    LayoutInflater inflater = getLayoutInflater();
    View inflatedView = inflater.inflate(R.layout.timeout, null);
    timeoutTimeLeftTextView = (TextView) inflatedView.findViewById(R.id.timeoutLeftTextView);
    timeoutPlaySymbol = (FloatingActionButton) inflatedView.findViewById(R.id.timeout_play_pause);
    builder.setView(inflatedView);

    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            if(timeoutPeriodicUpdate!=null)
            {
                timeoutPeriodicUpdate.cancel();
                timeoutPeriodicUpdate = null;
            }
        }
    });

    AlertDialog alertDialog = builder.create();
    alertDialog.setCanceledOnTouchOutside(false);
    alertDialog.show();
}
 
開發者ID:kingblaubart,項目名稱:quidditchtimekeeper,代碼行數:29,代碼來源:GameActivity.java

示例3: showSubtypeSelectorAndSettings

import android.app.AlertDialog; //導入方法依賴的package包/類
private void showSubtypeSelectorAndSettings() {
    final CharSequence title = getString(R.string.english_ime_input_options);
    // TODO: Should use new string "Select active input modes".
    final CharSequence languageSelectionTitle = getString(R.string.language_selection_title);
    final CharSequence[] items = new CharSequence[] {
            languageSelectionTitle,
            getString(ApplicationUtils.getActivityTitleResId(this, SettingsActivity.class))
    };
    final String imeId = mRichImm.getInputMethodIdOfThisIme();
    final OnClickListener listener = new OnClickListener() {
        @Override
        public void onClick(DialogInterface di, int position) {
            di.dismiss();
            switch (position) {
            case 0:
                final Intent intent = IntentUtils.getInputLanguageSelectionIntent(
                        imeId,
                        Intent.FLAG_ACTIVITY_NEW_TASK
                                | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
                                | Intent.FLAG_ACTIVITY_CLEAR_TOP);
                intent.putExtra(Intent.EXTRA_TITLE, languageSelectionTitle);
                startActivity(intent);
                break;
            case 1:
                launchSettings(SettingsActivity.EXTRA_ENTRY_VALUE_LONG_PRESS_COMMA);
                break;
            }
        }
    };
    final AlertDialog.Builder builder = new AlertDialog.Builder(
            DialogUtils.getPlatformDialogThemeContext(this));
    builder.setItems(items, listener).setTitle(title);
    final AlertDialog dialog = builder.create();
    dialog.setCancelable(true /* cancelable */);
    dialog.setCanceledOnTouchOutside(true /* cancelable */);
    showOptionDialog(dialog);
}
 
開發者ID:rkkr,項目名稱:simple-keyboard,代碼行數:38,代碼來源:LatinIME.java

示例4: alert

import android.app.AlertDialog; //導入方法依賴的package包/類
@WXModuleAnno
public void alert(String param, final JSCallback callback) {

  if (mWXSDKInstance.getContext() instanceof Activity) {

    String message = "";
    String okTitle = OK;
    if (!TextUtils.isEmpty(param)) {
      try {
        param = URLDecoder.decode(param, "utf-8");
        JSONObject jsObj = new JSONObject(param);
        message = jsObj.optString(MESSAGE);
        okTitle = jsObj.optString(OK_TITLE);
      } catch (Exception e) {
        WXLogUtils.e("[WXModalUIModule] alert param parse error ", e);
      }
    }
    if (TextUtils.isEmpty(message)) {
      message="";
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(mWXSDKInstance.getContext());
    builder.setMessage(message);

    final String okTitle_f = TextUtils.isEmpty(okTitle) ? OK : okTitle;
    builder.setPositiveButton(okTitle_f, new OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
        if(callback !=null) {
          callback.invoke(okTitle_f);
        }
      }
    });
    AlertDialog alertDialog = builder.create();
    alertDialog.setCanceledOnTouchOutside(false);
    alertDialog.show();
  } else {
    WXLogUtils.e("[WXModalUIModule] when call alert mWXSDKInstance.getContext() must instanceof Activity");
  }
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:40,代碼來源:WXModalUIModule.java

示例5: alert

import android.app.AlertDialog; //導入方法依賴的package包/類
@JSMethod(uiThread = true)
public void alert(String param, final JSCallback callback) {

  if (mWXSDKInstance.getContext() instanceof Activity) {

    String message = "";
    String okTitle = OK;
    if (!TextUtils.isEmpty(param)) {
      try {
        param = URLDecoder.decode(param, "utf-8");
        JSONObject jsObj = JSON.parseObject(param);
        message = jsObj.getString(MESSAGE);
        okTitle = jsObj.getString(OK_TITLE);
      } catch (Exception e) {
        WXLogUtils.e("[WXModalUIModule] alert param parse error ", e);
      }
    }
    if (TextUtils.isEmpty(message)) {
      message = "";
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(mWXSDKInstance.getContext());
    builder.setMessage(message);

    final String okTitle_f = TextUtils.isEmpty(okTitle) ? OK : okTitle;
    builder.setPositiveButton(okTitle_f, new OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int which) {
        if (callback != null) {
          callback.invoke(okTitle_f);
        }
      }
    });
    AlertDialog alertDialog = builder.create();
    alertDialog.setCanceledOnTouchOutside(false);
    alertDialog.show();
    tracking(alertDialog);
  } else {
    WXLogUtils.e("[WXModalUIModule] when call alert mWXSDKInstance.getContext() must instanceof Activity");
  }
}
 
開發者ID:weexext,項目名稱:ucar-weex-core,代碼行數:41,代碼來源:WXModalUIModule.java

示例6: buildBottomDialog

import android.app.AlertDialog; //導入方法依賴的package包/類
public static AlertDialog buildBottomDialog(Activity activity, View contentView) {
    AlertDialog dialog = new Builder(activity).create();
    dialog.setCanceledOnTouchOutside(true);
    dialog.show();
    dialog.setContentView(contentView);
    Window dialogWindow = dialog.getWindow();
    Display d = activity.getWindowManager().getDefaultDisplay();
    LayoutParams p = dialogWindow.getAttributes();
    p.width = d.getWidth();
    dialogWindow.setAttributes(p);
    dialogWindow.setGravity(80);
    return dialog;
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:14,代碼來源:DialogUtils.java

示例7: showConfirmCancelDialog

import android.app.AlertDialog; //導入方法依賴的package包/類
public static AlertDialog showConfirmCancelDialog(Context context,
												  String title, String message,
												  DialogInterface.OnClickListener posListener) {
	AlertDialog dlg = new AlertDialog.Builder(context).setMessage(message)
			.setPositiveButton("確認", posListener)
			.setNegativeButton("取消", null).create();
	dlg.setCanceledOnTouchOutside(false);
	dlg.show();
	return dlg;
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:11,代碼來源:Util.java

示例8: handleContactItemLongClick

import android.app.AlertDialog; //導入方法依賴的package包/類
public static void handleContactItemLongClick(final UserEntity contact, final Context ctx){
    if(contact == null || ctx == null){
        return;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(ctx, android.R.style.Theme_Holo_Light_Dialog));
    builder.setTitle(contact.getMainName());
    String[] items = new String[]{ctx.getString(R.string.check_profile),
            ctx.getString(R.string.start_session)};

    final long userId = contact.getPeerId();
    builder.setItems(items, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
                case 0 :
                    IMUIHelper.openUserProfileActivity(ctx, userId);
                    break;
                case 1 :
                    IMUIHelper.openChatActivity(ctx,contact.getSessionKey());
                    break;
            }
        }
    });
    AlertDialog alertDialog = builder.create();
    alertDialog.setCanceledOnTouchOutside(true);
    alertDialog.show();
}
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:29,代碼來源:IMUIHelper.java

示例9: handleContactItemLongClick

import android.app.AlertDialog; //導入方法依賴的package包/類
private void handleContactItemLongClick(final Context ctx, final RecentInfo recentInfo) {

        AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(ctx, android.R.style.Theme_Holo_Light_Dialog));
        builder.setTitle(recentInfo.getName());
        final boolean isTop = imService.getConfigSp().isTopSession(recentInfo.getSessionKey());

        int topMessageRes = isTop?R.string.cancel_top_message:R.string.top_message;
        String[] items = new String[]{ctx.getString(R.string.check_profile),
                ctx.getString(R.string.delete_session),
                ctx.getString(topMessageRes)};

        builder.setItems(items, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                switch (which) {
                    case 0 :
                        IMUIHelper.openUserProfileActivity(ctx, recentInfo.getPeerId());
                        break;
                    case 1 :
                        imService.getSessionManager().reqRemoveSession(recentInfo);
                        break;
                    case 2:{
                         imService.getConfigSp().setSessionTop(recentInfo.getSessionKey(),!isTop);
                    }break;
                }
            }
        });
        AlertDialog alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(true);
        alertDialog.show();
    }
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:32,代碼來源:ChatFragment.java

示例10: handleGroupItemLongClick

import android.app.AlertDialog; //導入方法依賴的package包/類
private void handleGroupItemLongClick(final Context ctx, final RecentInfo recentInfo) {

        AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(ctx, android.R.style.Theme_Holo_Light_Dialog));
        builder.setTitle(recentInfo.getName());

        final boolean isTop = imService.getConfigSp().isTopSession(recentInfo.getSessionKey());
        final boolean isForbidden = recentInfo.isForbidden();
        int topMessageRes = isTop?R.string.cancel_top_message:R.string.top_message;
        int forbidMessageRes =isForbidden?R.string.cancel_forbid_group_message:R.string.forbid_group_message;

        String[] items = new String[]{ctx.getString(R.string.delete_session),ctx.getString(topMessageRes),ctx.getString(forbidMessageRes)};

        builder.setItems(items, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                switch (which) {
                    case 0 :
                        imService.getSessionManager().reqRemoveSession(recentInfo);
                        break;
                    case 1:{
                        imService.getConfigSp().setSessionTop(recentInfo.getSessionKey(),!isTop);
                    }break;
                    case 2:{
                        // 底層成功會事件通知
                        int shieldType = isForbidden?DBConstant.GROUP_STATUS_ONLINE:DBConstant.GROUP_STATUS_SHIELD;
                        imService.getGroupManager().reqShieldGroup(recentInfo.getPeerId(),shieldType);
                    }
                    break;
                }
            }
        });
        AlertDialog alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(true);
        alertDialog.show();
    }
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:37,代碼來源:ChatFragment.java

示例11: newAlertDlg

import android.app.AlertDialog; //導入方法依賴的package包/類
/**
 * Creates new {@link AlertDialog}. Set canceled on touch outside to
 * {@code true}.
 * 
 * @param context
 *            the context which uses this library's theme.
 * @return {@link AlertDialog}
 * @since v4.3 beta
 */
public static AlertDialog newAlertDlg(Context context) {
    AlertDialog res = newAlertDlgBuilder(context).create();
    res.setCanceledOnTouchOutside(true);
    return res;
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:15,代碼來源:Dlg.java


注:本文中的android.app.AlertDialog.setCanceledOnTouchOutside方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。