Java Code Examples for android.app.AlertDialog#setView()

The following examples show how to use android.app.AlertDialog#setView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RepeaterIconSettingDialog.java    From QNotified with GNU General Public License v3.0 6 votes vote down vote up
public RepeaterIconSettingDialog(Context context) {
    dialog = (AlertDialog) CustomDialog.createFailsafe(context).setTitle("自定义+1图标").setPositiveButton("保存", this)
            .setNegativeButton("取消", null).setCancelable(true).create();
    ctx = dialog.getContext();
    dialog.setCanceledOnTouchOutside(false);
    @SuppressLint("InflateParams") View v = LayoutInflater.from(ctx).inflate(R.layout.select_repeater_icon_dialog, null);
    loadBtn = v.findViewById(R.id.selectRepeaterIcon_buttonLoadFile);
    loadBtn.setOnClickListener(this);
    browseBtn = v.findViewById(R.id.selectRepeaterIcon_buttonBrowseImg);
    browseBtn.setOnClickListener(this);
    restoreDefBtn = v.findViewById(R.id.selectRepeaterIcon_buttonRestoreDefaultIcon);
    restoreDefBtn.setOnClickListener(this);
    prevImgView = v.findViewById(R.id.selectRepeaterIcon_imageViewPreview);
    prevImgView.setPadding(1, 1, 1, 1);
    prevImgView.setBackgroundDrawable(new DebugDrawable(ctx));
    specDpi = v.findViewById(R.id.selectRepeaterIcon_checkBoxSpecifyDpi);
    specDpi.setOnCheckedChangeListener(this);
    dpiGroup = v.findViewById(R.id.selectRepeaterIcon_RadioGroupDpiList);
    dpiGroup.setOnCheckedChangeListener(this);
    pathInput = v.findViewById(R.id.selectRepeaterIcon_editTextIconLocation);
    linearLayoutDpi = v.findViewById(R.id.selectRepeaterIcon_linearLayoutDpi);
    textViewWarning = v.findViewById(R.id.selectRepeaterIcon_textViewWarnMsg);
    physicalDpi = ctx.getResources().getDisplayMetrics().densityDpi;
    dialog.setView(v);
}
 
Example 2
Source File: Editor.java    From editor with GNU General Public License v3.0 6 votes vote down vote up
private void saveAsDialog(String path,
                          DialogInterface.OnClickListener listener)
{
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.save);
    builder.setMessage(R.string.choose);

    // Add the buttons
    builder.setPositiveButton(R.string.save, listener);
    builder.setNegativeButton(R.string.cancel, listener);

    // Create edit text
    Context context = builder.getContext();
    EditText text = new EditText(context);
    text.setId(R.id.path_text);
    text.setText(path);

    // Create the AlertDialog
    AlertDialog dialog = builder.create();
    dialog.setView(text, 40, 0, 40, 0);
    dialog.show();
}
 
Example 3
Source File: Main.java    From currency with GNU General Public License v3.0 6 votes vote down vote up
private void updateDialog(int title, String value, int hint,
                          DialogInterface.OnClickListener listener)
{
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(title);

    // Add the buttons
    builder.setPositiveButton(R.string.ok, listener);
    builder.setNegativeButton(R.string.cancel, listener);

    // Create edit text
    Context context = builder.getContext();
    EditText text = new EditText(context);
    text.setId(R.id.value);
    text.setText(value);
    text.setHint(hint);
    text.setInputType(InputType.TYPE_CLASS_NUMBER |
                      InputType.TYPE_NUMBER_FLAG_DECIMAL);

    // Create the AlertDialog
    AlertDialog dialog = builder.create();
    dialog.setView(text, 40, 0, 40, 0);
    dialog.show();
}
 
Example 4
Source File: TimelineActivity.java    From twittererer with Apache License 2.0 6 votes vote down vote up
private void showNewTweetDialog() {
    final EditText tweetText = new EditText(this);
    tweetText.setId(R.id.tweet_text);
    tweetText.setSingleLine();
    tweetText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
    tweetText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(140)});
    tweetText.setImeOptions(EditorInfo.IME_ACTION_DONE);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage(R.string.label_what_is_happening);
    builder.setPositiveButton(R.string.action_tweet, (dialog, which) -> presenter.tweet(tweetText.getText().toString()));

    AlertDialog alert = builder.create();
    alert.setView(tweetText, 64, 0, 64, 0);
    alert.show();

    tweetText.setOnEditorActionListener((v, actionId, event) -> {
        if (actionId == EditorInfo.IME_ACTION_DONE) {
            alert.getButton(DialogInterface.BUTTON_POSITIVE).callOnClick();
            return true;
        }
        return false;
    });
}
 
Example 5
Source File: ArticleInfoListFragment.java    From travelguide with Apache License 2.0 5 votes vote down vote up
private void showLicense()
{
  final WebView wb = new WebView(getActivity());
  wb.loadUrl("file:///android_asset/license.html");

  final AlertDialog ad =
  new AlertDialog.Builder(getActivity())
     .setTitle(R.string.about)
     .setCancelable(true)
     .create();
  ad.setCanceledOnTouchOutside(true);
  ad.setView(wb);
  ad.show();
}
 
Example 6
Source File: QuestionWidget.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
/**
 * Display extra help, triggered by user request.
 */
private void fireHelpText(final Runnable r) {
    if (!mPrompt.hasHelp()) {
        return;
    }

    // Depending on ODK setting, help may be displayed either as
    // a dialog or inline, underneath the question text

    if (showHelpWithDialog()) {
        AlertDialog mAlertDialog = new AlertDialog.Builder(this.getContext()).create();
        ScrollView scrollView = new ScrollView(this.getContext());
        scrollView.addView(createHelpLayout());
        mAlertDialog.setView(scrollView);

        DialogInterface.OnClickListener errorListener = (dialog, i) -> {
            switch (i) {
                case DialogInterface.BUTTON1:
                    dialog.cancel();
                    if (r != null) r.run();
                    break;
            }
        };
        mAlertDialog.setCancelable(true);
        mAlertDialog.setButton(StringUtils.getStringSpannableRobust(this.getContext(), R.string.ok), errorListener);
        mAlertDialog.show();
    } else {

        if (helpPlaceholder.getVisibility() == View.GONE) {
            expand(helpPlaceholder);
        } else {
            collapse(helpPlaceholder);
        }
    }
}
 
Example 7
Source File: ViewInject.java    From KJFrameForAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * 返回一个自定义View对话框
 */
public AlertDialog getDialogView(Context cxt, String title, View view) {
    AlertDialog dialog = new AlertDialog.Builder(cxt).create();
    dialog.setMessage(title);
    dialog.setView(view);
    dialog.show();
    return dialog;
}
 
Example 8
Source File: CustomedDialog.java    From evercam-android with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Return a pop up dialog that shows camera snapshot.
 *
 * @param bitmap the returned image Bitmap to show in pop up dialog
 */
public static AlertDialog getSnapshotDialog(final Activity activity, Bitmap bitmap) {
    Builder builder = new AlertDialog.Builder(activity);
    final AlertDialog snapshotDialog = builder.create();

    snapshotDialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);

    LayoutInflater mInflater = LayoutInflater.from(activity);
    final View snapshotView = mInflater.inflate(R.layout.dialog_test_snapshot, null);
    Button nextButton = (Button) snapshotView.findViewById(R.id.connect_camera_next_button);

    if (activity instanceof AddCameraActivity) {
        nextButton.setVisibility(View.VISIBLE);
        nextButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ((AddCameraActivity) activity).showCameraNameView();
                snapshotDialog.dismiss();
            }
        });
    }
    ImageView snapshotImageView = (ImageView) snapshotView.findViewById(R.id
            .test_snapshot_image);
    snapshotImageView.setImageBitmap(bitmap);
    snapshotDialog.setView(snapshotView);

    return snapshotDialog;
}