Example usage for android.app AlertDialog findViewById

List of usage examples for android.app AlertDialog findViewById

Introduction

In this page you can find the example usage for android.app AlertDialog findViewById.

Prototype

@Nullable
public <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID or null if the ID is invalid (< 0), there is no matching view in the hierarchy, or the dialog has not yet been fully created (for example, via #show() or #create() ).

Usage

From source file:com.outsystemscloud.andrevieira.secureDevice.java

@SuppressLint("NewApi")
private void changeTextDirection(Builder dlg) {
    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    dlg.create();/*from  ww w.  j  a v a  2  s.c  o  m*/
    AlertDialog dialog = dlg.show();
    if (currentapiVersion >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
        TextView messageview = (TextView) dialog.findViewById(android.R.id.message);
        messageview.setTextDirection(android.view.View.TEXT_DIRECTION_LOCALE);
    }
}

From source file:com.vuze.android.remote.dialog.DialogFragmentRcmAuthAll.java

@Override
public void onResume() {
    super.onResume();
    AlertDialog d = (AlertDialog) getDialog();
    if (d != null) {
        final Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE);
        final CheckBox cbYesAlready = (CheckBox) d.findViewById(R.id.rcm_cb_all);

        positiveButton.setEnabled(cbYesAlready.isChecked());

        OnCheckedChangeListener l = new CompoundButton.OnCheckedChangeListener() {
            @Override//ww w.java  2s.  com
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                positiveButton.setEnabled(cbYesAlready.isChecked());
            }
        };
        cbYesAlready.setOnCheckedChangeListener(l);
    }
}

From source file:com.vuze.android.remote.dialog.DialogFragmentRcmAuth.java

@Override
public void onResume() {
    super.onResume();
    AlertDialog d = (AlertDialog) getDialog();
    if (d != null) {
        final Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE);
        final RadioButton rbPre = (RadioButton) d.findViewById(R.id.rcm_rb_pre);
        final RadioButton rbAll = (RadioButton) d.findViewById(R.id.rcm_rb_all);

        all = rbAll.isChecked();//  w  w w .ja  v  a 2  s  .  c  o  m

        positiveButton.setEnabled(rbPre.isChecked() || rbAll.isChecked());

        OnCheckedChangeListener l = new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                positiveButton.setEnabled(rbPre.isChecked() || rbAll.isChecked());
                all = rbAll.isChecked();
            }
        };

        rbPre.setOnCheckedChangeListener(l);
        rbAll.setOnCheckedChangeListener(l);
    }
}

From source file:com.retroteam.studio.retrostudio.MainActivity.java

/**
 * Show app information in a popup./*from ww  w. j a  v a2  s .  c  o m*/
 */

private void showAbout() {
    AlertDialog.Builder about = new AlertDialog.Builder(this);
    about.setTitle("About").setIcon(R.mipmap.ic_launcher)
            .setMessage(Html.fromHtml(getString(R.string.about_us_html))).setCancelable(false)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
    AlertDialog aboutpop = about.create();
    aboutpop.show();
    // make links clickable
    ((TextView) aboutpop.findViewById(android.R.id.message))
            .setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:com.tassadar.multirommgr.MainActivity.java

@TargetApi(20)
private void showDeprecatedLAlert() {
    SpannableString msg = new SpannableString(getString(R.string.deprecated_l_text));
    Linkify.addLinks(msg, Linkify.ALL);/*w  w w  .  ja v a2 s  .  c o m*/

    AlertDialog.Builder b = new AlertDialog.Builder(this);
    b.setTitle(R.string.deprecated_l_title).setCancelable(false).setMessage(msg)
            .setNegativeButton(R.string.deprecated_l_btn, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    finish();
                }
            });

    AlertDialog d = b.create();
    d.show();

    TextView msgView = (TextView) d.findViewById(android.R.id.message);
    msgView.setMovementMethod(LinkMovementMethod.getInstance());
}

From source file:com.android.leanlauncher.SettingsActivity.java

private void displayAboutDialog() {
    findPreference(getString(R.string.pref_about))
            .setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
                @Override//from   w w w  .  j  a v  a 2 s .  c  o m
                public boolean onPreferenceClick(Preference preference) {
                    String about = String.format(getString(R.string.about_application),
                            BuildConfig.VERSION_NAME);

                    AlertDialog d = new AlertDialog.Builder(SettingsActivity.this)
                            .setIcon(R.mipmap.ic_launcher_home).setCancelable(true)
                            .setTitle(R.string.application_name).setMessage(Html.fromHtml(about)).create();
                    d.show();
                    ((TextView) d.findViewById(android.R.id.message))
                            .setMovementMethod(LinkMovementMethod.getInstance());

                    return false;
                }
            });
}

From source file:com.danielme.muspyforandroid.activities.base.AbstractActivity.java

/**
 * <b>Call always after dialog.show!!!!!!!!!</b>
 * /* w  w  w  . j a v  a 2  s  .co  m*/
 * @param alertDialog
 */
public void dialogStyle(AlertDialog alertDialog) {
    TextView textView = (TextView) alertDialog.findViewById(android.R.id.message);
    if (textView != null) {
        textView.setBackgroundDrawable(null);
        textView.setTextAppearance(this, R.style.muspydialogmessage);
    }
    Button button = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
    if (button != null) {
        button.setBackgroundDrawable(getResources().getDrawable(R.drawable.textbuttonselector));
    }
    button = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
    if (button != null) {
        button.setBackgroundDrawable(getResources().getDrawable(R.drawable.textbuttonselector));
    }
    button = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
    if (button != null) {
        button.setBackgroundDrawable(getResources().getDrawable(R.drawable.textbuttonselector));
    }
}

From source file:com.shalzz.attendance.fragment.CaptchaDialogFragment.java

@NonNull
@Override/* w w w. j a  v  a 2 s . c o  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    LayoutInflater inflater = getActivity().getLayoutInflater();

    builder.setView(inflater.inflate(R.layout.captcha_dialog, null)).setTitle("Input Captcha")
            .setIcon(R.drawable.ic_menu_edit).setCancelable(true)
            .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    mListener.onDialogPositiveClick(CaptchaDialogFragment.this);
                }
            });

    final AlertDialog alertDialog = builder.create();
    alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {

            EditText captxt = (EditText) alertDialog.findViewById(R.id.etCapTxt);
            Miscellaneous.showKeyboard(getActivity(), captxt);

            Button positiveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
            positiveButton.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    EditText captxt = (EditText) alertDialog.findViewById(R.id.etCapTxt);
                    if (captxt.getText().toString().length() != 6) {
                        captxt.setError("Captcha must be of 6 digits");
                        Miscellaneous.showKeyboard(getActivity(), captxt);
                    } else
                        mListener.onDialogPositiveClick(CaptchaDialogFragment.this);
                }
            });
        }
    });

    return alertDialog;
}

From source file:itvector.wineguide.ui.wines.MainActivity.java

@Override
public void onShowDescription(WineModel wineModels) {
    AlertDialog builder = new AlertDialog.Builder(this).setCancelable(true)
            .setTitle(R.string.dialog_title_description)
            .setMessage(StringUtils.capitalize(wineModels.getWine_type()))
            .setPositiveButton(R.string.button_ok, (dialog, id) -> dialog.dismiss()).create();
    builder.show();//from  w  w w. jav  a2s.  c o m

    TextView textView = (TextView) builder.findViewById(android.R.id.message);
    textView.setTextSize(getResources().getDimension(R.dimen.dialog_message_description));
}

From source file:com.pranavpandey.smallapp.sample.SmallAppSample.java

private void showSettings() {
    LayoutInflater inflater = LayoutInflater.from(getContext());
    View view = inflater.inflate(R.layout.settings, new LinearLayout(this), false);

    ViewGroup clearDefaults;//  www .ja v  a  2s.c  o m

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
    alertDialogBuilder.setTitle(R.string.sas_settings).setView(view).setPositiveButton(android.R.string.ok,
            null);
    final AlertDialog alertDialog = alertDialogBuilder.create();

    // Create dialog using SmallUtils as we have to show it from a service
    SmallUtils.createDialog(alertDialog, getRootView().getWindowToken()).show();

    clearDefaults = (ViewGroup) alertDialog.findViewById(R.id.view_clear_defaults);

    clearDefaults.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            // Clear all the associated apps
            (new Associations(getContext())).getHelper().clearAll(true);
        }
    });
}