當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。