当前位置: 首页>>代码示例>>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;未经允许,请勿转载。