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:de.baumann.browser.about.About_content.java

static MaterialAboutList createMaterialAboutList(final Context c) {
    MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder();

    // Add items to card

    appCardBuilder.addItem(/*from  w w  w . j  a v a  2s  .  c  o m*/
            new MaterialAboutTitleItem.Builder().text(R.string.app_name).icon(R.mipmap.ic_launcher).build());

    try {

        appCardBuilder.addItem(ConvenienceBuilder.createVersionActionItem(c,
                ContextCompat.getDrawable(c, R.drawable.earth2), "Version", false));

    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }

    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_changelog)
            .subText(R.string.about_changelog_summary).icon(R.drawable.format_list_bulleted2)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c,
                    c.getString(R.string.about_changelog),
                    "https://github.com/scoute-dich/browser/blob/master/CHANGELOG.md", true, false))
            .build());

    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_license)
            .subText(R.string.about_license_summary).icon(R.drawable.copyright)
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    final AlertDialog d = new AlertDialog.Builder(c).setTitle(R.string.about_title)
                            .setMessage(helper_main.textSpannable(c.getString(R.string.about_text)))
                            .setPositiveButton(c.getString(R.string.toast_yes),
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface dialog, int id) {
                                            dialog.cancel();
                                        }
                                    })
                            .show();
                    d.show();
                    ((TextView) d.findViewById(android.R.id.message))
                            .setMovementMethod(LinkMovementMethod.getInstance());
                }
            }).build());

    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_intro)
            .subText(R.string.about_intro_summary).icon(R.drawable.information_outline)
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    Intent intent = new Intent(c, Activity_intro.class);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                    c.startActivity(intent);
                }
            }).build());

    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_help)
            .subText(R.string.about_help_summary).icon(R.drawable.help_circle_outline)
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    final AlertDialog d = new AlertDialog.Builder(c).setTitle(R.string.about_help)
                            .setMessage(helper_main.textSpannable(c.getString(R.string.help_text)))
                            .setPositiveButton(c.getString(R.string.toast_yes),
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface dialog, int id) {
                                            dialog.cancel();
                                        }
                                    })
                            .show();
                    d.show();
                    ((TextView) d.findViewById(android.R.id.message))
                            .setMovementMethod(LinkMovementMethod.getInstance());
                }
            }).build());

    MaterialAboutCard.Builder authorCardBuilder = new MaterialAboutCard.Builder();
    authorCardBuilder.title(R.string.about_title_dev);

    authorCardBuilder
            .addItem(new MaterialAboutActionItem.Builder().text(R.string.about_dev)
                    .subText(R.string.about_dev_summary).icon(R.drawable.gaukler_faun)
                    .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c,
                            c.getString(R.string.about_dev), "https://github.com/scoute-dich/", true, false))
                    .build());

    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_donate)
            .subText(R.string.about_donate_summary).icon(R.drawable.coin)
            .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse(
                    "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NP6TGYDYP9SHY")))
            .build());

    MaterialAboutCard.Builder convenienceCardBuilder = new MaterialAboutCard.Builder();
    convenienceCardBuilder.title(R.string.about_title_libs);

    convenienceCardBuilder
            .addItem(new MaterialAboutActionItem.Builder().text("Android Observable ScrollView")
                    .subText(R.string.about_license_2).icon(R.drawable.github_circle)
                    .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c,
                            "Android Observable ScrollView",
                            "https://github.com/ksoichiro/Android-ObservableScrollView", true, false))
                    .build());

    convenienceCardBuilder
            .addItem(new MaterialAboutActionItem.Builder().text("Android Onboarder")
                    .subText(R.string.about_license_3).icon(R.drawable.github_circle)
                    .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c,
                            "Android Onboarder", "https://github.com/chyrta/AndroidOnboarder", true, false))
                    .build());

    convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Glide")
            .subText(R.string.about_license_9).icon(R.drawable.github_circle)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Glide",
                    "https://github.com/bumptech/glide", true, false))
            .build());

    convenienceCardBuilder
            .addItem(new MaterialAboutActionItem.Builder().text("MAH Encryptor Lib")
                    .subText(R.string.about_license_6).icon(R.drawable.github_circle)
                    .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c,
                            "MAH Encryptor Lib", "https://github.com/hummatli/MAHEncryptorLib", true, false))
                    .build());

    convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Material About Library")
            .subText(R.string.about_license_7).icon(R.drawable.github_circle)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Material About Library",
                    "https://github.com/daniel-stoneuk/material-about-library", true, false))
            .build());

    convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Material Design Icons")
            .subText(R.string.about_license_8).icon(R.drawable.github_circle)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Material Design Icons",
                    "https://github.com/Templarian/MaterialDesign", true, false))
            .build());

    return new MaterialAboutList(appCardBuilder.build(), authorCardBuilder.build(),
            convenienceCardBuilder.build());
}

From source file:de.baumann.pdfcreator.about.About_content.java

static MaterialAboutList createMaterialAboutList(final Context c) {
    MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder();

    // Add items to card

    appCardBuilder.addItem(//  w w  w.ja  v  a 2 s .c om
            new MaterialAboutTitleItem.Builder().text(R.string.app_name).icon(R.mipmap.ic_launcher).build());

    try {

        appCardBuilder.addItem(ConvenienceBuilder.createVersionActionItem(c,
                ContextCompat.getDrawable(c, R.drawable.earth2), "Version", false));

    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }

    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_changelog)
            .subText(R.string.about_changelog_summary).icon(R.drawable.format_list_bulleted)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c,
                    c.getString(R.string.about_changelog),
                    "https://github.com/scoute-dich/PDFCreator/blob/master/CHANGELOG.md", true, false))
            .build());

    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_license)
            .subText(R.string.about_license_summary).icon(R.drawable.copyright)
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    final AlertDialog d = new AlertDialog.Builder(c).setTitle(R.string.about_title)
                            .setMessage(helper_main.textSpannable(c.getString(R.string.about_text)))
                            .setPositiveButton(c.getString(R.string.toast_yes),
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface dialog, int id) {
                                            dialog.cancel();
                                        }
                                    })
                            .show();
                    d.show();
                    ((TextView) d.findViewById(android.R.id.message))
                            .setMovementMethod(LinkMovementMethod.getInstance());
                }
            }).build());

    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_intro)
            .subText(R.string.about_intro_summary).icon(R.drawable.information_outline)
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    Intent intent = new Intent(c, Activity_intro.class);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                    c.startActivity(intent);
                }
            }).build());

    MaterialAboutCard.Builder authorCardBuilder = new MaterialAboutCard.Builder();
    authorCardBuilder.title(R.string.about_title_dev);

    authorCardBuilder
            .addItem(new MaterialAboutActionItem.Builder().text(R.string.about_dev)
                    .subText(R.string.about_dev_summary).icon(R.drawable.gaukler_faun)
                    .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c,
                            c.getString(R.string.about_dev), "https://github.com/scoute-dich/", true, false))
                    .build());

    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_donate)
            .subText(R.string.about_donate_summary).icon(R.drawable.coin)
            .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse(
                    "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NP6TGYDYP9SHY")))
            .build());

    MaterialAboutCard.Builder authorCardBuilder2 = new MaterialAboutCard.Builder();
    authorCardBuilder2.title(R.string.about_title_con);

    authorCardBuilder2.addItem(new MaterialAboutActionItem.Builder().text("Neofaum")
            .subText(R.string.about_title_con1).icon(R.drawable.github_circle)
            .setOnClickListener(
                    ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/naofum")))
            .build());

    MaterialAboutCard.Builder authorCardBuilder3 = new MaterialAboutCard.Builder();
    authorCardBuilder3.title(R.string.about_title_ext);

    authorCardBuilder3.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_ext)
            .subText(R.string.about_ext_summary).icon(R.drawable.gaukler_faun)
            .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(c,
                    Uri.parse("https://github.com/scoute-dich/MuPDF/releases")))
            .build());

    MaterialAboutCard.Builder convenienceCardBuilder = new MaterialAboutCard.Builder();
    convenienceCardBuilder.title(R.string.about_title_libs);

    convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Android Image Cropper")
            .subText(R.string.about_license_2).icon(R.drawable.github_circle)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Android Image Cropper",
                    "https://github.com/ArthurHub/Android-Image-Cropper", true, false))
            .build());

    convenienceCardBuilder
            .addItem(new MaterialAboutActionItem.Builder().text("Android Onboarder")
                    .subText(R.string.about_license_3).icon(R.drawable.github_circle)
                    .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c,
                            "Android Onboarder", "https://github.com/chyrta/AndroidOnboarder", true, false))
                    .build());

    convenienceCardBuilder
            .addItem(new MaterialAboutActionItem.Builder().text("Android PDFView")
                    .subText(R.string.about_license_6).icon(R.drawable.github_circle)
                    .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c,
                            "Android PDFView", "https://github.com/JoanZapata/android-pdfview", true, false))
                    .build());

    convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Glide")
            .subText(R.string.about_license_9).icon(R.drawable.github_circle)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Glide",
                    "https://github.com/bumptech/glide", true, false))
            .build());

    convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("GPUImage for Android")
            .subText(R.string.about_license_4).icon(R.drawable.github_circle)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "GPUImage for Android",
                    "https://github.com/CyberAgent/android-gpuimage", true, false))
            .build());

    convenienceCardBuilder
            .addItem(
                    new MaterialAboutActionItem.Builder().text("Image Picker").subText(R.string.about_license_1)
                            .icon(R.drawable.github_circle)
                            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c,
                                    "Image Picker", "https://github.com/Mariovc/ImagePicker", true, false))
                            .build());

    convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("iText")
            .subText(R.string.about_license_5).icon(R.drawable.github_circle)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "iText",
                    "https://github.com/itext/itextpdf", true, false))
            .build());

    convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Material About Library")
            .subText(R.string.about_license_7).icon(R.drawable.github_circle)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Material About Library",
                    "https://github.com/daniel-stoneuk/material-about-library", true, false))
            .build());

    convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Material Design Icons")
            .subText(R.string.about_license_8).icon(R.drawable.github_circle)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Material Design Icons",
                    "https://github.com/Templarian/MaterialDesign", true, false))
            .build());

    return new MaterialAboutList(appCardBuilder.build(), authorCardBuilder.build(), authorCardBuilder2.build(),
            authorCardBuilder3.build(), convenienceCardBuilder.build());
}

From source file:com.zns.comicdroid.dialog.RenameDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    LayoutInflater inflater = getActivity().getLayoutInflater();
    final View view = inflater.inflate(R.layout.dialog_rename, null);
    ((EditText) view.findViewById(R.id.dialogRename_etName)).setText(mName);

    builder.setView(view);//  ww w  . ja v a 2 s  .  com

    builder.setPositiveButton(getResources().getString(R.string.common_save),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    AlertDialog ad = (AlertDialog) dialog;
                    EditText etName = (EditText) ad.findViewById(R.id.dialogRename_etName);

                    if (mRenameCallback != null)
                        mRenameCallback.onDialogPositiveClick(mName, etName.getText().toString());
                }
            })

            .setNegativeButton(getResources().getString(R.string.common_cancel),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            RenameDialogFragment.this.getDialog().cancel();
                        }
                    });

    AlertDialog dialog = builder.create();
    return dialog;
}

From source file:com.commonsware.android.dbasset.ConstantsFragment.java

public void onClick(DialogInterface di, int whichButton) {
    ContentValues values = new ContentValues(2);
    AlertDialog dlg = (AlertDialog) di;
    EditText title = (EditText) dlg.findViewById(R.id.title);
    EditText value = (EditText) dlg.findViewById(R.id.value);

    values.put(DatabaseHelper.TITLE, title.getText().toString());
    values.put(DatabaseHelper.VALUE, value.getText().toString());

    task = new InsertTask().execute(values);
}

From source file:com.mobicage.rogerthat.util.ui.UIUtils.java

public static void setDialogButtonColors(Context ctx, AlertDialog dialog) {
    int primaryColor = LookAndFeelConstants.getPrimaryColor(ctx);
    // This may or may not change in different SDK versions
    int buttonId1 = ctx.getResources().getIdentifier("android:id/button1", null, null);
    ((Button) dialog.findViewById(buttonId1)).setTextColor(primaryColor);
    int buttonId2 = ctx.getResources().getIdentifier("android:id/button2", null, null);
    ((Button) dialog.findViewById(buttonId2)).setTextColor(primaryColor);
    int buttonId3 = ctx.getResources().getIdentifier("android:id/button3", null, null);
    ((Button) dialog.findViewById(buttonId3)).setTextColor(primaryColor);
}

From source file:com.commonsware.android.constants.ConstantsFragment.java

public void onClick(DialogInterface di, int whichButton) {
    ContentValues values = new ContentValues(2);
    AlertDialog dlg = (AlertDialog) di;
    EditText title = dlg.findViewById(R.id.title);
    EditText value = dlg.findViewById(R.id.value);

    values.put(DatabaseHelper.TITLE, title.getText().toString());
    values.put(DatabaseHelper.VALUE, value.getText().toString());

    final ContentResolver cr = getActivity().getContentResolver();

    new Thread() {
        @Override// w  w  w .j a  v a2 s .  c o m
        public void run() {
            cr.insert(Provider.Constants.CONTENT_URI, values);
        }
    }.start();
}

From source file:id.nci.stm_9.FileDialogFragment.java

/**
 * Updates filename in dialog, normally called in onActivityResult in activity using the
 * FileDialog//from   w w w . j  a v  a2s.  c  o m
 * 
 * @param messageId
 * @param progress
 * @param max
 */
public void setFilename(String filename) {
    AlertDialog dialog = (AlertDialog) getDialog();
    EditText filenameEditText = (EditText) dialog.findViewById(R.id.input);

    if (filenameEditText != null) {
        filenameEditText.setText(filename);
    }
}

From source file:org.totschnig.myexpenses.dialog.ExportDialogFragment.java

@Override
public void onClick(DialogInterface dialog, int which) {
    Bundle args = getArguments();//from   ww w.ja v a2s.  c o  m
    Long accountId = args != null ? args.getLong("accountId") : null;
    Intent i;
    Activity ctx = getActivity();
    AlertDialog dlg = (AlertDialog) dialog;
    String format = ((RadioGroup) dlg.findViewById(R.id.format)).getCheckedRadioButtonId() == R.id.csv ? "CSV"
            : "QIF";
    String dateFormat = ((EditText) dlg.findViewById(R.id.date_format)).getText().toString();
    MyApplication.getInstance().getSettings().edit().putString(MyApplication.PREFKEY_EXPORT_FORMAT, format)
            .putString(PREFKEY_EXPORT_DATE_FORMAT, dateFormat).commit();
    boolean deleteP = ((CheckBox) dlg.findViewById(R.id.export_delete)).isChecked();
    boolean notYetExportedP = ((CheckBox) dlg.findViewById(R.id.export_not_yet_exported)).isChecked();
    if (Utils.isExternalStorageAvailable()) {
        if (accountId == null)
            Feature.RESET_ALL.recordUsage();
        i = new Intent(ctx, Export.class).putExtra(KEY_ROWID, accountId).putExtra("format", format)
                .putExtra("deleteP", deleteP).putExtra("notYetExportedP", notYetExportedP)
                .putExtra("dateFormat", dateFormat);
        ctx.startActivityForResult(i, 0);
    } else {
        Toast.makeText(ctx, ctx.getString(R.string.external_storage_unavailable), Toast.LENGTH_LONG).show();
    }
}

From source file:org.thialfihar.android.apg.ui.dialog.FileDialogFragment.java

/**
 * Updates filename in dialog, normally called in onActivityResult in activity using the
 * FileDialog// ww w.jav  a2 s  .c  om
 */
private void setFilename(String filename) {
    AlertDialog dialog = (AlertDialog) getDialog();
    EditText filenameEditText = (EditText) dialog.findViewById(R.id.input);

    if (filenameEditText != null) {
        filenameEditText.setText(filename);
    }
}

From source file:org.rm3l.ddwrt.tiles.admin.nvram.EditNVRAMKeyValueDialogFragment.java

@Override
public void onStart() {
    super.onStart(); //super.onStart() is where dialog.show() is actually called on the underlying dialog, so we have to do it after this point

    final AlertDialog d = (AlertDialog) getDialog();
    if (d != null) {

        ((TextView) d.findViewById(R.id.tile_admin_nvram_edit_key)).setText(this.mKey);
        final EditText valueEditText = (EditText) d.findViewById(R.id.tile_admin_nvram_edit_value);
        valueEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override//from w ww.j a va 2 s  .  com
            public void onFocusChange(View v, boolean hasFocus) {
                ((TextView) d.findViewById(R.id.tile_admin_nvram_edit_value_textview)).setTypeface(null,
                        hasFocus ? Typeface.BOLD_ITALIC : Typeface.NORMAL);
            }
        });
        valueEditText.setText(this.mValue, TextView.BufferType.EDITABLE);

        d.getButton(Dialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //Validate data
                final EditText editText = (EditText) d.findViewById(R.id.tile_admin_nvram_edit_value);
                final Editable newValue = editText.getText();

                if (mValue != null && StringUtils.equals(newValue.toString(), mValue.toString())) {
                    //Crouton
                    Crouton.makeText(getActivity(), "No change", ALERT,
                            (ViewGroup) (d.findViewById(R.id.tile_admin_nvram_edit_notification_viewgroup)))
                            .show();
                    editText.requestFocus();
                    //Open Keyboard
                    final InputMethodManager imm = (InputMethodManager) getActivity()
                            .getSystemService(Context.INPUT_METHOD_SERVICE);
                    if (imm != null) {
                        // only will trigger it if no physical keyboard is open
                        imm.showSoftInput(editText, 0);
                    }
                    return;
                }

                final CharSequence variableKey = ((TextView) d.findViewById(R.id.tile_admin_nvram_edit_key))
                        .getText();

                final Bundle token = new Bundle();
                token.putInt(POSITION, mPosition);
                token.putCharSequence(VALUE, newValue);
                token.putCharSequence(KEY, variableKey);

                //nvram set data changed
                new UndoBarController.UndoBar(getSherlockActivity())
                        .message(String.format("Variable '%s' will be updated", variableKey))
                        .listener(nvramDataRecyclerViewAdapter).token(token).show();

                d.cancel();
            }
        });
    }
}