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


Java AlertDialog.setOnShowListener方法代码示例

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


在下文中一共展示了AlertDialog.setOnShowListener方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateDialog

import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@SuppressLint("InflateParams")
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    LayoutInflater layoutInflater = getActivity().getLayoutInflater();
    View rootView = layoutInflater.inflate(R.layout.dialog_add_language_goal, null);
    unbinder = ButterKnife.bind(this, rootView);

    autoCompleteTextView.setAdapter(new ArrayAdapter<>(
            getActivity(), android.R.layout.simple_dropdown_item_1line, validLanguages));
    validator = new LanguageValidator(getActivity(), autoCompleteTextView, validLanguages);
    autoCompleteTextView.setValidator(validator);
    autoCompleteTextView.setOnFocusChangeListener(new FocusListener());
    autoCompleteTextView.setThreshold(1);
    autoCompleteTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            autoCompleteTextView.showDropDown();
        }
    });

    hoursPicker.setMinValue(1);
    hoursPicker.setMaxValue(24);
    hoursPicker.setValue(hoursPicked);


    builder.setView(rootView)
            .setPositiveButton(R.string.ok, null)
            .setNegativeButton(R.string.cancel, null);

    AlertDialog dialog = builder.create();
    dialog.setOnShowListener(this);

    return dialog;
}
 
开发者ID:Protino,项目名称:CodeWatch,代码行数:37,代码来源:LanguageGoalFragment.java

示例2: showCredentialsDialog

import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
private void showCredentialsDialog(final DeviceDAO deviceDAO) {
    final View content = View.inflate(this, R.layout.dialog_device_protected, null);
    final AlertDialog d = new AlertDialog.Builder(this)
            .setTitle(R.string.dialog_device_protected_title)
            .setPositiveButton(android.R.string.yes, null)
            .setNegativeButton(R.string.cancel, null)
            .setView(content).create();

    d.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(final DialogInterface dialog) {
            Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
            button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    EditText username = content.findViewById(R.id.deviceUsername);
                    EditText password = content.findViewById(R.id.devicePassword);
                    if (TextUtils.isEmpty(username.getText())) {
                        username.setError(getString(R.string.dialog_error_field_required));
                        username.requestFocus();
                    } else if (TextUtils.isEmpty(password.getText())) {
                        password.setError(getString(R.string.dialog_error_field_required));
                        password.requestFocus();
                    } else {
                        dialog.dismiss();
                        deviceDAO.setUsername(username.getText().toString());
                        deviceDAO.setPassword(password.getText().toString());
                        checkCredentials(deviceDAO);
                    }
                }
            });
        }
    });
    d.show();
}
 
开发者ID:MBach,项目名称:home-automation,代码行数:36,代码来源:ScanActivity.java

示例3: create

import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@Override
public AlertDialog create() {
    AlertDialog ret = super.create();
    ret.setOnShowListener((DialogInterface dialogInterface) -> {
        themeButton(ret.getButton(AlertDialog.BUTTON_POSITIVE));
        themeButton(ret.getButton(AlertDialog.BUTTON_NEGATIVE));
        themeButton(ret.getButton(AlertDialog.BUTTON_NEUTRAL));
    });
    return ret;
}
 
开发者ID:MCMrARM,项目名称:revolution-irc,代码行数:11,代码来源:ThemedAlertDialog.java

示例4: onCreateDialog

import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    // creazione 'manuale' del dialog
    int margin = getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin);

    LinearLayout rootView = new LinearLayout(getActivity());
    rootView.setOrientation(LinearLayout.VERTICAL);
    rootView.setPadding(margin, margin, margin, margin);
    mTxtInput = new TextInputLayout(getActivity());
    mTxtInput.addView(new EditText(getActivity()));
    mTxtInput.setHint(getString(R.string.api_key_title));
    if (mTxtInput.getEditText() != null) {
        mTxtInput.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        mTxtInput.getEditText().setHighlightColor(Color.YELLOW);
    }

    rootView.addView(mTxtInput);

    // Setto l'edit text con il testo dell'api key se presente
    String apiKey = SharedPrefsHelper.getInstance().getApiKey(getActivity());
    if(apiKey != null)
        mTxtInput.getEditText().setText(apiKey);

    AlertDialog dialog = new AlertDialog.Builder(getActivity())
            .setTitle(getString(R.string.title_insert_api_key))
            .setView(rootView)
            //.setCancelable(false)
            .setPositiveButton(getString(R.string.salva), null)
            .setNegativeButton(SharedPrefsHelper.getInstance()
                    .isApiKeyRegistered(getActivity()) ? getString(R.string.annulla) : getString(R.string.esci_app), this)
            .create();

    dialog.setOnShowListener(this);

    return dialog;
}
 
开发者ID:IelloDevTeam,项目名称:IelloAndroidAdminApp,代码行数:39,代码来源:DialogAPIKey.java

示例5: 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

示例6: sendDebugLogEmail

import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
private void sendDebugLogEmail(final StringBuilder body) {
    final LinearLayout layout = new LinearLayout(getContext());
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(32,16,32,16);


    final TextView title = new TextView(getContext());
    title.setText("Explain the problem below:");
    title.setTextSize(18);
    final EditText input = new EditText(getContext());
    layout.addView(title);
    layout.addView(input);

    final AlertDialog dialog = new AlertDialog.Builder(getContext())
            .setTitle("Send Logs: Step 1")
            .setView(layout)
            .setPositiveButton(android.R.string.ok, null)
            .setNegativeButton(android.R.string.cancel, null)
            .create();

    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialogInterface) {

            Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
            button.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    String issue = input.getText().toString();
                    issue = issue.trim();
                    if (issue.isEmpty()) {
                        Toast.makeText(getContext(), "You must describe the problem you are facing to proceed!", Toast.LENGTH_SHORT).show();
                    } else {
                        body.insert(0, "\n\n------\n\n");
                        body.insert(0, issue);

                        DebugLog log = DebugLog.get(getActivity());
                        startActivity(log.emailLogIntent(getContext(), body.toString()));

                        mEnableLogs.setChecked(false);
                        dialog.dismiss();
                    }
                }
            });
        }
    });

    dialog.show();
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:52,代码来源:HomeFragment.java

示例7: sendFeedback

import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
private void sendFeedback() {
    final LinearLayout layout = new LinearLayout(HomeActivity.this);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(32,16,32,16);

    final TextView title = new TextView(HomeActivity.this);
    title.setText("Enter your feedback below:");
    title.setTextSize(18);
    final EditText input = new EditText(HomeActivity.this);
    layout.addView(title);
    layout.addView(input);

    final AlertDialog dialog = new AlertDialog.Builder(HomeActivity.this)
        .setTitle("Send Feedback: Step 1")
        .setView(layout)
        .setPositiveButton(android.R.string.ok, null)
        .setNegativeButton(android.R.string.cancel, null)
        .create();

    dialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialogInterface) {

            Button button = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
            button.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    String feedback = input.getText().toString();
                    feedback = feedback.trim();
                    if (feedback.isEmpty()) {
                        Toast.makeText(HomeActivity.this, "You must type some feedback to proceed!", Toast.LENGTH_SHORT).show();
                    } else {
                        feedback += "\n\n";
                        String uriText =
                                "mailto:[email protected]" +
                                        "?subject=" + Uri.encode(getString(R.string.email_subject)) +
                                        "&body=" + Uri.encode(feedback);

                        Uri uri = Uri.parse(uriText);

                        Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
                        sendIntent.setData(uri);
                        startActivity(Intent.createChooser(sendIntent, "Step 2: Select app to send feedback"));

                        dialog.dismiss();
                    }
                }
            });
        }
    });

    dialog.show();
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:56,代码来源:HomeActivity.java

示例8: onCreateDialog

import android.support.v7.app.AlertDialog; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final AlertDialog dialog = (AlertDialog) super.onCreateDialog(savedInstanceState);

    layoutInflater = dialog.getLayoutInflater();

    View content = onCreateContentView(savedInstanceState);

    // Intermediate view with custom message TextView
    View intermediate = inflate(R.layout.simpledialogfragment_custom_view);
    TextView textView = (TextView) intermediate.findViewById(R.id.customMessage);
    View topSpacer = intermediate.findViewById(R.id.textSpacerNoTitle);
    ViewGroup container = (ViewGroup) intermediate.findViewById(R.id.customView);
    container.addView(content);

    dialog.setView(intermediate);


    String msg = getArgString(MESSAGE);
    if (msg != null) {
        CharSequence message;
        if (getArguments().getBoolean(HTML)) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                message = Html.fromHtml(msg, 0);
            } else {
                //noinspection deprecation
                message = Html.fromHtml(msg);
            }
        } else {
            message = msg;
        }
        textView.setText(message);

    } else {
        textView.setVisibility(View.GONE);
    }
    dialog.setMessage(null);

    topSpacer.setVisibility(getArgString(TITLE) == null && msg != null ? View.VISIBLE : View.GONE);


    dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface d) {
            positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
            positiveButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    pressPositiveButton();
                }
            });
            onDialogShown();

        }
    });

    return dialog;
}
 
开发者ID:eltos,项目名称:SimpleDialogFragments,代码行数:60,代码来源:CustomViewDialog.java


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