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


Java AlertDialog.show方法代码示例

本文整理汇总了Java中android.app.AlertDialog.show方法的典型用法代码示例。如果您正苦于以下问题:Java AlertDialog.show方法的具体用法?Java AlertDialog.show怎么用?Java AlertDialog.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.AlertDialog的用法示例。


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

示例1: showErrorMsgBox

import android.app.AlertDialog; //导入方法依赖的package包/类
public void showErrorMsgBox(String strErrMsg, final String strNextAction)	{
	AlertDialog.Builder blder = new AlertDialog.Builder(this);
	blder.setIcon(R.drawable.icon);
	blder.setTitle(getString(R.string.error));
	blder.setMessage(strErrMsg);
	blder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
		
		@Override
		public void onClick(DialogInterface dialog, int which) {
			if (strNextAction.equalsIgnoreCase("WhatsNew"))	{
				showWhatsNewBox();
			}
		}
	});
	blder.setCancelable(false);
	AlertDialog alertErrDlg = blder.create();
	alertErrDlg.show();
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:19,代码来源:ActivitySmartCalc.java

示例2: onEnterStartedState

import android.app.AlertDialog; //导入方法依赖的package包/类
private void onEnterStartedState() {
    Log.d(TAG, "call onEnterStartedState");
    /* Connect camera */
    if (!connectCamera(getWidth(), getHeight())) {
        AlertDialog ad = new AlertDialog.Builder(getContext()).create();
        ad.setCancelable(false); // This blocks the 'BACK' button
        ad.setMessage("It seems that you device does not support camera (or it is locked). Application will be closed.");
        ad.setButton(DialogInterface.BUTTON_NEUTRAL,  "OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                ((Activity) getContext()).finish();
            }
        });
        ad.show();

    }
}
 
开发者ID:johnhany,项目名称:MOAAP,代码行数:18,代码来源:CameraBridgeViewBase.java

示例3: dialogBookBike

import android.app.AlertDialog; //导入方法依赖的package包/类
private void dialogBookBike(String stationName) {
    AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
    builder1.setMessage("Booking successful in " + stationName + ". Choose your bike!");
    builder1.setCancelable(true);
    builder1.setPositiveButton(
            "Ok",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    final GlobalClass globalVariable = (GlobalClass) getApplicationContext();
                    globalVariable.setBooking(true);
                    dialog.cancel();
                }
            });

    AlertDialog alert11 = builder1.create();
    alert11.show();
}
 
开发者ID:carlosfaria94,项目名称:UbiBike-client,代码行数:18,代码来源:Station.java

示例4: showAlert

import android.app.AlertDialog; //导入方法依赖的package包/类
/**
 * Show dialog
 * @param context Context
 * @param title Title
 * @param layoutResource Layout resource id
 * @param iconResource Icon resource id
 * @return AlertDialog Dialog
 */
static AlertDialog showAlert(Context context, CharSequence title, int layoutResource, int iconResource) {
    @SuppressLint("InflateParams")
    View view = ((Activity) context).getLayoutInflater().inflate(layoutResource, null, false);
    AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(title);
    alertDialog.setView(view);
    if (iconResource > 0) {
        alertDialog.setIcon(iconResource);
    }
    alertDialog.show();
    return alertDialog;
}
 
开发者ID:bfabiszewski,项目名称:ulogger-android,代码行数:21,代码来源:Alert.java

示例5: oneButtonAlert

import android.app.AlertDialog; //导入方法依赖的package包/类
public static void oneButtonAlert(Activity activity,String message, String title, String buttonText) {
  Log.i(LOG_TAG, "One button alert " + message);
  AlertDialog alertDialog = new AlertDialog.Builder(activity).create();
  alertDialog.setTitle(title);
  // prevents the user from escaping the dialog by hitting the Back button
  alertDialog.setCancelable(false);
  alertDialog.setMessage(stringToHTML(message));
  alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL,
      buttonText, new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
    }});
  alertDialog.show();
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:14,代码来源:Notifier.java

示例6: onOptionsItemSelected

import android.app.AlertDialog; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem pItem) {
    if (pItem.getTitle().equals(getString(R.string.sort))) {
        final CharSequence[] items = {"Newest First", "Oldest First"};

        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle(R.string.sort);
        builder.setSingleChoiceItems(items, mSortType, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int item) {
                dialog.dismiss();
                if (mSortType == item)
                    return;
                switch (item) {
                    case 0:
                        mAdapter.sort(HistoryRecord.SortByTimeStampDESC);
                        break;
                    case 1:
                        mAdapter.sort(HistoryRecord.SortByTimeStampASC);
                        break;
                }
                mSortType = item;
            }
        });
        AlertDialog alert = builder.create();
        alert.show();
        return true;
    } else if (pItem.getTitle().equals(getString(R.string.clear))) {
        MAVApplication.getInstance().getRepository().deleteHistoryRecords();
        mAdapter.clear();
        return true;
    }
    return super.onOptionsItemSelected(pItem);
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:35,代码来源:HistoryMaterialFragment.java

示例7: Alert

import android.app.AlertDialog; //导入方法依赖的package包/类
public static void Alert(Context c, String szTitle, String szMessage) {
    if (c instanceof Activity && ((Activity) c).isFinishing())
        return;

    AlertDialog.Builder builder = new AlertDialog.Builder(c);
    builder.setMessage(szMessage);
    builder.setTitle(szTitle);
    builder.setNegativeButton(c.getString(R.string.lblOK), (dialog, id) -> dialog.cancel());
    AlertDialog alert = builder.create();
    alert.show();
}
 
开发者ID:ericberman,项目名称:MyFlightbookAndroid,代码行数:12,代码来源:MFBUtil.java

示例8: showDialogFinish

import android.app.AlertDialog; //导入方法依赖的package包/类
public void showDialogFinish(final OrderDetail orderDetail){
    final AlertDialog dialog_finish;
    AlertDialog.Builder builder = new AlertDialog.Builder(context,R.style.DialogTransBackGround);
    dialog_finish = builder.create();
    dialog_finish.setCancelable(true);
    dialog_finish.show();
    View view_dialog = LayoutInflater.from(context).inflate(R.layout.item_dialog_confirm, null);
    dialog_finish.setContentView(view_dialog);
    TextView tv_title = (TextView) view_dialog.findViewById(R.id.tv_dialog_title);
    TextView tv_content = (TextView) view_dialog.findViewById(R.id.tv_dialog_content);
    Button bt_yes = (Button) view_dialog.findViewById(R.id.bt_dialog_yes);

    tv_title.setText("提示");
    tv_content.setText("确定要申请退货吗?");
    bt_yes.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog_finish.dismiss();

            if (orderDetail.state == 4) {
                if (orderDetail.orderDetailId == 0) {
                    Toast.makeText(context, "orderDetailId为空!", Toast.LENGTH_SHORT).show();
                } else {
                    orderDetail.state = 5;
                    orderDetail.refundStatus = 1;
                    notifyDataSetChanged();
                    MyOrderActivity.instance.refundOrder(orderId, orderDetail.orderDetailId);
                }
            }
        }
    });
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:33,代码来源:OrderInfoFinishAdapter.java

示例9: showFirstOvertimeShoutAlerts

import android.app.AlertDialog; //导入方法依赖的package包/类
public void showFirstOvertimeShoutAlerts()
{
    if(game.activeTime == 1)
    {
        long remaining = game.clocks[game.activeTime].getTimeRemaining();
        for(int ii=0; ii<game.firstOvertimeReminderTimes.size();ii++)
        {
            boolean timeBoundaryPassed = remaining<=game.firstOvertimeReminderTimes.get(ii) && remaining>(game.firstOvertimeReminderTimes.get(ii)-1000); // second argument prevents execution on large gap (i.e., when time jumps)
            boolean checkedAlready = previousRemaining <= game.firstOvertimeReminderTimes.get(ii);
            if(timeBoundaryPassed && !checkedAlready)
            {
                if(!firstOvertimeSoundPlayed.get(ii))
                {
                    firstOvertimeSoundPlayed.set(ii, true);
                    alert1.start();
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(context);
                if(game.firstOvertimeReminderInstructionTitles.get(ii) != null) builder.setTitle(game.firstOvertimeReminderInstructionTitles.get(ii));
                if(game.firstOvertimeReminderInstructionMessages.get(ii) != null) builder.setMessage(game.firstOvertimeReminderInstructionMessages.get(ii));

                builder.setPositiveButton("OK", new DialogInterface.OnClickListener()
                {
                    public void onClick(DialogInterface dialog, int which)
                    {
                        dialog.dismiss();
                    }
                });

                AlertDialog alertDialog = builder.create();
                alertDialog.show();
            }
        }
        previousRemaining = game.clocks[game.activeTime].getTimeRemaining();
    }
}
 
开发者ID:kingblaubart,项目名称:quidditchtimekeeper,代码行数:36,代码来源:GameActivity.java

示例10: animatePlayPause

import android.app.AlertDialog; //导入方法依赖的package包/类
public void animatePlayPause(View w)
{
    if(game.clocks[game.activeTime].getMode().equals("timer") && !game.clocks[game.activeTime].isRunning() && game.clocks[game.activeTime].getTimeRemaining()==0)
    {
        //nicht starten
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle("You can't start the timer because it is already 00:00.");

        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {

                dialog.dismiss();

            } });

        AlertDialog alertDialog = builder.create();
        alertDialog.show();
    }
    else
    {
        toggleWatches();
        AnimatedVectorDrawable drawable = play ? playToPause : pauseToPlay;
        playPause[game.activeTime].setImageDrawable(drawable);
        drawable.start();
        play = !play;
    }
}
 
开发者ID:kingblaubart,项目名称:quidditchtimekeeper,代码行数:28,代码来源:GameActivity.java

示例11: onLayout

import android.app.AlertDialog; //导入方法依赖的package包/类
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
	super.onLayout(changed, left, top, right, bottom);

	try {
		onLayout2(changed, left, top, right, bottom);
	}
	catch (java.lang.OutOfMemoryError e) {
		System.out.println("Out of memory during layout");

		// we might get an out of memory error.
		// so let's display an alert.
		// TODO: a better message, in resources.

		if (!memAlert) {
			memAlert = true;
			AlertDialog alertDialog = MuPDFActivity.getAlertBuilder().create();
			alertDialog.setMessage("Out of memory during layout");
			alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						dialog.dismiss();
						memAlert = false;
					}
				});
			alertDialog.show();
		}
	}
}
 
开发者ID:ArtifexSoftware,项目名称:mupdf-android-viewer-old,代码行数:30,代码来源:ReaderView.java

示例12: showDialogDatePicker

import android.app.AlertDialog; //导入方法依赖的package包/类
public void showDialogDatePicker(){
    AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.DialogTransBackGround);
    final AlertDialog dialog_date = builder.create();
    dialog_date.show();
    View view_dialog = LayoutInflater.from(context).inflate(R.layout.item_dialog_datepicker, null);
    dialog_date.setContentView(view_dialog);
    DatePicker picker = (DatePicker) view_dialog.findViewById(R.id.date_picker);
    Button bt_yes = (Button) view_dialog.findViewById(R.id.bt_yes);
    Button bt_no = (Button) view_dialog.findViewById(R.id.bt_no);

    Calendar calendar = Calendar.getInstance();
    int int_Year = calendar.get(Calendar.YEAR);
    int int_Month = calendar.get(Calendar.MONTH);
    int int_Day = calendar.get(Calendar.DAY_OF_MONTH);

    time = int_Year + "-" + String.format("%02d", (int_Month + 1)) + "-" + String.format("%02d", int_Day);
    picker.init(int_Year, int_Month, int_Day, new DatePicker.OnDateChangedListener() {
        @Override
        public void onDateChanged(DatePicker datePicker, int i, int i1, int i2) {
            Log.e("aaa", "" + i2);
            time = i + "-" + String.format("%02d", (i1 + 1)) + "-" + String.format("%02d", i2);
        }
    });
    bt_yes.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            et_add_time.setText(time);
            dialog_date.dismiss();
        }
    });
    bt_no.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog_date.dismiss();
        }
    });
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:38,代码来源:AddCaseActivity.java

示例13: showDialogRound

import android.app.AlertDialog; //导入方法依赖的package包/类
public void showDialogRound(){
    AlertDialog.Builder builder = new AlertDialog.Builder(context, R.style.DialogTransBackGround);
    final AlertDialog dialog_date = builder.create();
    dialog_date.show();
    View view_dialog = LayoutInflater.from(context).inflate(R.layout.item_dialog_addcase_round, null);
    dialog_date.setContentView(view_dialog);
    LoopView loopView = (LoopView) view_dialog.findViewById(R.id.loopView);
    Button bt_yes = (Button) view_dialog.findViewById(R.id.bt_yes);
    Button bt_no = (Button) view_dialog.findViewById(R.id.bt_no);

    final ArrayList<String> list = new ArrayList<>();
    list.add("种子轮");
    list.add("天使轮");
    list.add("A轮");
    list.add("B轮");
    list.add("C轮");
    loopView.setTextSize(17);
    loopView.setInitPosition(0);
    loopView.setCenterTextColor(getResources().getColor(R.color.colorAppRed));
    loopView.setItemsVisibleCount(5);
    loopView.setItems(list);
    loopView.setListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(int index) {
            et_add_rounds.setText(list.get(index));
        }
    });
    bt_yes.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog_date.dismiss();
        }
    });
    bt_no.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog_date.dismiss();
        }
    });
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:41,代码来源:AddCaseActivity.java

示例14: showAlertDialog

import android.app.AlertDialog; //导入方法依赖的package包/类
private void showAlertDialog(String message) {
    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Alert");
    alertDialog.setMessage(message);
    alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alertDialog.show();
}
 
开发者ID:freeloki,项目名称:AndroidThings-BurglarAlarm,代码行数:13,代码来源:LoginActivity.java

示例15: onOptionsItemSelected

import android.app.AlertDialog; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem pItem) {
    if (pItem.getTitle().equals(getString(R.string.sort))) {
        final CharSequence[] items = {"Newest First", "Oldest First"};

        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle(R.string.sort);
        builder.setSingleChoiceItems(items, mSortType, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int item) {
                dialog.dismiss();
                if (mSortType == item)
                    return;
                switch (item) {
                    case 0:
                        mAdapter.sort(OfflineHistoryRecord.SortByTimeStampDESC);
                        break;
                    case 1:
                        mAdapter.sort(OfflineHistoryRecord.SortByTimeStampASC);
                        break;
                }
                mSortType = item;
            }
        });
        AlertDialog alert = builder.create();
        alert.show();
        return true;
    } else if (pItem.getTitle().equals(getString(R.string.clear))) {
        MAVApplication.getInstance().getRepository().deleteOfflineHistoryRecords();
        mAdapter.clear();
        return true;
    }
    return super.onOptionsItemSelected(pItem);
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:35,代码来源:OfflineHistoryMaterialFragment.java


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