当前位置: 首页>>代码示例>>Java>>正文


Java AlertDialog.setOnDismissListener方法代码示例

本文整理汇总了Java中android.support.v7.app.AlertDialog.setOnDismissListener方法的典型用法代码示例。如果您正苦于以下问题:Java AlertDialog.setOnDismissListener方法的具体用法?Java AlertDialog.setOnDismissListener怎么用?Java AlertDialog.setOnDismissListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.app.AlertDialog的用法示例。


在下文中一共展示了AlertDialog.setOnDismissListener方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
    }
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:21,代码来源:CrashReportActivity.java

示例2: showDisclaimerForFirstTime

import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
private void showDisclaimerForFirstTime() {
    final SharedPreferences preferences = getActivity().getSharedPreferences("temp", Context.MODE_PRIVATE);
    final String hasShown = "hasShown";
    if (preferences.getBoolean(hasShown, false)) {
        return;
    }

    AlertDialog alertDialog = new AlertDialog.Builder(getActivity())
            .setTitle("This is still in beta!")
            .setMessage("Data is not yet finished nor complete. Please help us via Github. Links available in the drawer.")
            .setPositiveButton("Ok no problem!", null)
            .show();
    alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            preferences.edit().putBoolean(hasShown, true).apply();
        }
    });
}
 
开发者ID:ZafraniTechLLC,项目名称:Companion-For-PUBG-Android,代码行数:20,代码来源:ItemFragment.java

示例3: 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);
    }
}
 
开发者ID:nextgis,项目名称:android_nextgis_mobile,代码行数:36,代码来源:PermissionUtil.java

示例4: show

import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
public void show() {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(titleRes);
    View view = View.inflate(context, R.layout.dialog_enter_text, null);

    final EditText input = (EditText) view.findViewById(R.id.editText);
    input.setText(value);
    input.setSelection(input.getText().length());

    if (hint != null) {
        input.setHint(hint);
    }

    input.setInputType(inputType);
    builder.setView(view);
    builder.setPositiveButton(R.string.button_ok, null);
    builder.setNegativeButton(R.string.button_cancel, (dialog, which) -> dialog.cancel());

    final AlertDialog alertDialog = builder.create();
    alertDialog.setOnShowListener(dialog -> {
        Button b = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);

        b.setOnClickListener(view1 -> {
            input.setError(null);
            String newValue = input.getText().toString().trim();

            if (TextUtils.isEmpty(newValue) && !allowEmpty) {
                input.setError(context.getString(R.string.field_is_required));
                input.requestFocus();
            } else {
                try {
                    if (validator != null) {
                        validator.validate(newValue);
                    }

                    if (callback != null) {
                        callback.onChanged(newValue);
                    }

                    if (target != null) {
                        target.setText(newValue);
                    }

                    alertDialog.dismiss();
                } catch (IllegalArgumentException e) {
                    input.setError(e.getMessage());
                    input.requestFocus();
                }
            }
        });
    });

    alertDialog.setOnDismissListener(onDismissListener);
    alertDialog.show();

    input.post(() -> {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(input, InputMethodManager.SHOW_IMPLICIT);
    });
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:61,代码来源:InputTextDialog.java


注:本文中的android.support.v7.app.AlertDialog.setOnDismissListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。