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


Java AlertDialog类代码示例

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


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

示例1: onHeightClick

import android.support.v7.app.AlertDialog; //导入依赖的package包/类
@OnClick(R.id.custom_tile_height_size)
public void onHeightClick() {
  final NumberPicker view = new NumberPicker(this);
  view.setMinValue(24);
  view.setMaxValue(64);
  view.setWrapSelectorWheel(false);
  view.setValue(currentTileHeight);
  new AlertDialog.Builder(this)
          .setView(view)
          .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(@NonNull DialogInterface dialog, int which) {
              currentTileHeight = view.getValue();
              widget.setTileHeightDp(currentTileHeight);
            }
          })
          .show();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:CustomTileDimensions.java

示例2: addWords

import android.support.v7.app.AlertDialog; //导入依赖的package包/类
public void addWords() {
    LayoutInflater inflater = activity.getLayoutInflater();
    View mView = inflater.inflate(R.layout.dialog_edit_extra_words, (ViewGroup) activity.findViewById(R.id.dialog_layout_edit_words));
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(R.string.add);
    final TextInputEditText word_1 = mView.findViewById(R.id.edittext_edit_word_1);
    final TextInputEditText word_2 = mView.findViewById(R.id.edittext_edit_word_2);
    builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String edit_1 = word_1.getText().toString();
            String edit_2 = word_2.getText().toString();
            if (!edit_1.isEmpty() && !edit_2.isEmpty()) {
                ExtraWord.add(new String[]{edit_1, edit_2});
                hasEdited = true;
                notifyDataSetChanged();
            } else {
                Toast.makeText(activity, R.string.edit_extra_words_error, Toast.LENGTH_SHORT).show();
            }
        }
    });
    builder.setNegativeButton(android.R.string.no, null);
    builder.setView(mView);
    builder.show();
}
 
开发者ID:XFY9326,项目名称:CatchSpy,代码行数:26,代码来源:EditListAdapter.java

示例3: showResultDialog

import android.support.v7.app.AlertDialog; //导入依赖的package包/类
private void showResultDialog(final String message, int code) {

        try {
            final AlertDialog dialog = new AlertDialog.Builder(this)
                    .setTitle(getString(com.mobillium.paparasdk.R.string.title))
                    .setMessage(message + " (" + code + ")")
                    .setPositiveButton(getString(R.string.done), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            dialogInterface.dismiss();
                        }
                    })
                    .create();

            dialog.setCanceledOnTouchOutside(false);
            dialog.show();

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
 
开发者ID:paparateam,项目名称:papara-android,代码行数:22,代码来源:MainActivity.java

示例4: buildMdLoadingVertical

import android.support.v7.app.AlertDialog; //导入依赖的package包/类
protected BuildBean buildMdLoadingVertical(BuildBean bean) {
    AlertDialog.Builder builder = new AlertDialog.Builder(bean.mContext);
    View root = View.inflate(bean.mContext, R.layout.dialogui_loading_vertical, null);
    View llBg = (View) root.findViewById(R.id.dialogui_ll_bg);
    ProgressBar pbBg = (ProgressBar) root.findViewById(R.id.pb_bg);
    TextView tvMsg = (TextView) root.findViewById(R.id.dialogui_tv_msg);
    tvMsg.setText(bean.msg);
    if (bean.isWhiteBg) {
        llBg.setBackgroundResource(R.drawable.dialogui_shape_wihte_round_corner);
        pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_rotate_mum));
        tvMsg.setTextColor(bean.mContext.getResources().getColor(R.color.text_black));
    } else {
        llBg.setBackgroundResource(R.drawable.dialogui_shape_gray_round_corner);
        pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_rotate_mum_light));
        tvMsg.setTextColor(Color.WHITE);
    }
    builder.setView(root);
    AlertDialog dialog = builder.create();
    bean.alertDialog = dialog;
    return bean;
}
 
开发者ID:weileng11,项目名称:KUtils-master,代码行数:22,代码来源:Buildable.java

示例5: ColorPickerDialogBuilder

import android.support.v7.app.AlertDialog; //导入依赖的package包/类
private ColorPickerDialogBuilder(Context context, int theme) {
	defaultMargin = getDimensionAsPx(context, R.dimen.default_slider_margin);
	final int dialogMarginBetweenTitle = getDimensionAsPx(context, R.dimen.default_slider_margin_btw_title);

	builder = new AlertDialog.Builder(context, theme);
	pickerContainer = new LinearLayout(context);
	pickerContainer.setOrientation(LinearLayout.VERTICAL);
	pickerContainer.setGravity(Gravity.CENTER_HORIZONTAL);
	pickerContainer.setPadding(defaultMargin, dialogMarginBetweenTitle, defaultMargin, defaultMargin);

	LinearLayout.LayoutParams layoutParamsForColorPickerView = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0);
	layoutParamsForColorPickerView.weight = 1;
	colorPickerView = new ColorPickerView(context);

	pickerContainer.addView(colorPickerView, layoutParamsForColorPickerView);

	builder.setView(pickerContainer);
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:19,代码来源:ColorPickerDialogBuilder.java

示例6: gotosetper

import android.support.v7.app.AlertDialog; //导入依赖的package包/类
void gotosetper(float percentageall)
{
    LayoutInflater inflater = getLayoutInflater();
    View alertLayout = inflater.inflate(R.layout.layoutforperall, null);
    TextView pe=(TextView)alertLayout.findViewById(R.id.peralllll);
    AlertDialog.Builder alert = new AlertDialog.Builder(this);




    // this is set the view from XML inside AlertDialog
    alert.setView(alertLayout);
    // disallow cancel of AlertDialog on click of back button and outside touch


    final AlertDialog dialog = alert.create();
    dialog.show();
    pe.setText("Your Overall percentage is : "+percentageall+"%"+"\n");
    Button ok=(Button)alertLayout.findViewById(R.id.button11);
    ok.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
}
 
开发者ID:iamjaspreetsingh,项目名称:TrackPlan-app,代码行数:27,代码来源:MainActivity.java

示例7: downloadBook

import android.support.v7.app.AlertDialog; //导入依赖的package包/类
@OnClick(R.id.tvBookReadDownload)
public void downloadBook() {
    gone(rlReadAaSet);
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("缓存多少章?")
            .setItems(new String[]{"后面五十章", "后面全部", "全部"}, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    switch (which) {
                        case 0:
                            DownloadBookService.post(new DownloadQueue(bookId, mChapterList, currentChapter + 1, currentChapter + 50));
                            break;
                        case 1:
                            DownloadBookService.post(new DownloadQueue(bookId, mChapterList, currentChapter + 1, mChapterList.size()));
                            break;
                        case 2:
                            DownloadBookService.post(new DownloadQueue(bookId, mChapterList, 1, mChapterList.size()));
                            break;
                        default:
                            break;
                    }
                }
            });
    builder.show();
}
 
开发者ID:zwmlibs,项目名称:BookReader-master,代码行数:26,代码来源:ReadActivity.java

示例8: getInput

import android.support.v7.app.AlertDialog; //导入依赖的package包/类
public static void getInput(Context context, String title, DialogInterface.OnClickListener onOkListener)
{
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(title);

    final EditText input = new EditText(context);
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    input.setId(R.id.text1);
    builder.setView(input);

    builder.setPositiveButton("OK", onOkListener);

    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    builder.show();
}
 
开发者ID:fekracomputers,项目名称:MuslimMateAndroid,代码行数:22,代码来源:Utility.java

示例9: onPostExecute

import android.support.v7.app.AlertDialog; //导入依赖的package包/类
@Override
protected void onPostExecute(Certificate certificate) {
    progressDialog.dismiss();

    if (certificate != null) {
        StorageUtils.saveObject(PersoActivity.this, getString(R.string.tls_client_cert_key), certificate);
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(PersoActivity.this);
        builder.setTitle(R.string.perso_problem_title);
        builder.setMessage(R.string.perso_problem_register);
        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                finish();
            }
        });
        builder.create().show();
    }
}
 
开发者ID:mDL-ILP,项目名称:mDL-ILP,代码行数:20,代码来源:PersoActivity.java

示例10: initializeLinks

import android.support.v7.app.AlertDialog; //导入依赖的package包/类
private void initializeLinks() {
  TextView        failureText     = (TextView) findViewById(R.id.sms_failed_text);
  String          pretext         = getString(R.string.registration_progress_activity__signal_timed_out_while_waiting_for_a_verification_sms_message);
  String          link            = getString(R.string.RegistrationProblemsActivity_possible_problems);
  SpannableString spannableString = new SpannableString(pretext + " " + link);

  spannableString.setSpan(new ClickableSpan() {
    @Override
    public void onClick(View widget) {
      new AlertDialog.Builder(RegistrationProgressActivity.this)
              .setTitle(R.string.RegistrationProblemsActivity_possible_problems)
              .setView(R.layout.registration_problems)
              .setNeutralButton(android.R.string.ok, null)
              .show();
    }
  }, pretext.length() + 1, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

  failureText.setText(spannableString);
  failureText.setMovementMethod(LinkMovementMethod.getInstance());
}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:21,代码来源:RegistrationProgressActivity.java

示例11: onCreateDialog

import android.support.v7.app.AlertDialog; //导入依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Bundle args = getArguments();
    final AspectRatio[] ratios = (AspectRatio[]) args.getParcelableArray(ARG_ASPECT_RATIOS);
    if (ratios == null) {
        throw new RuntimeException("No ratios");
    }
    Arrays.sort(ratios);
    final AspectRatio current = args.getParcelable(ARG_CURRENT_ASPECT_RATIO);
    final AspectRatioAdapter adapter = new AspectRatioAdapter(ratios, current);
    return new AlertDialog.Builder(getActivity()).setAdapter(adapter, new DialogInterface
            .OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int position) {
            mListener.onAspectRatioSelected(ratios[position]);
        }
    }).create();
}
 
开发者ID:viseator,项目名称:MontageCam,代码行数:20,代码来源:AspectRatioFragment.java

示例12: handleResult

import android.support.v7.app.AlertDialog; //导入依赖的package包/类
@Override
public void handleResult(Result result) {
    if (result.getText().split(":").length > 2) {
        ContentValues contentValues = new ContentValues();
        contentValues.put(DatabaseContract.TableTransactions.COL_DATE, getAmount(result.getText(), DATE)); // bug
        contentValues.put(DatabaseContract.TableTransactions.COL_AMOUNT, getAmount(result.getText(), AMOUNT)); // bug

        AddTxService.insertNewTx(getApplicationContext(), contentValues);
        Intent goBackToMain = new Intent(this, MainActivity.class);
        startActivity(goBackToMain);
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Scan Result");
        builder.setMessage("Not a valid value");
        builder.show();
    }
}
 
开发者ID:talCrafts,项目名称:Udhari,代码行数:18,代码来源:QrCodeActivity.java

示例13: showEditTextDialog

import android.support.v7.app.AlertDialog; //导入依赖的package包/类
@SuppressLint("InflateParams")
public static AlertDialog showEditTextDialog(BaseActivity activity, String title, String content,
                                             boolean isPassword, EditTextDialogCallback callback) {
    View layout = LayoutInflater.from(activity).inflate(R.layout.view_dialog_edit_text, null);
    EditText input = (EditText) layout.findViewById(R.id.edit_text);
    input.setText(content);
    if (isPassword) {
        input.setInputType(InputType.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD);
    }
    input.setSelection(input.getText().length());

    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(title);
    builder.setView(layout);
    builder.setPositiveButton("确定", (dialog, which) -> {
        if (callback != null) {
            callback.onSuccess(input.getText().toString());
        }
    });
    builder.setNegativeButton("取消", (dialog, which) -> dialog.dismiss());

    return builder.show();
}
 
开发者ID:dss886,项目名称:Transmis,代码行数:24,代码来源:DialogBuilder.java

示例14: showPopupMenu

import android.support.v7.app.AlertDialog; //导入依赖的package包/类
private void showPopupMenu(View view) {
    final CharSequence[] items = {"Edit", "Delete"};
    view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    AlertDialog.Builder builder = new AlertDialog.Builder(mContext);

    builder.setTitle(mTextName.getText());
    builder.setItems(items, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            int position = getAdapterPosition();
            switch (which){
                case 0://Edit
                    listener.editTask(position);
                    break;
                case 1://Delete
                    listener.deleteTask(position);
                    break;
            }
        }
    });
    builder.show();
}
 
开发者ID:swapyx,项目名称:Channelize,代码行数:23,代码来源:ToDoListAdapter.java

示例15: takePhoto

import android.support.v7.app.AlertDialog; //导入依赖的package包/类
public void takePhoto(View view) {
    String[] items = new String[]{getString(R.string.output_dialog_external),
            getString(R.string.output_dialog_mediastore)};

    new AlertDialog.Builder(this)
            .setTitle(getString(R.string.output_dialog_title))
            .setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Uri outputUri = null;
                    if (which == 0) {
                        outputUri = getExternalStorageUri();
                    }
                    takePhoto(outputUri);
                    dialog.dismiss();
                }
            }).show();
}
 
开发者ID:marchinram,项目名称:RxGallery,代码行数:19,代码来源:MainActivity.java


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