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