本文整理汇总了Java中android.app.AlertDialog.Builder类的典型用法代码示例。如果您正苦于以下问题:Java Builder类的具体用法?Java Builder怎么用?Java Builder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Builder类属于android.app.AlertDialog包,在下文中一共展示了Builder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rapporterOgvisFejl
import android.app.AlertDialog.Builder; //导入依赖的package包/类
public static void rapporterOgvisFejl(final Activity akt, final Exception e) {
if (!App.EMULATOR) {
Crashlytics.logException(e);
//Mint.logException(e);
}
Log.e(e);
Builder ab = new Builder(akt);
ab.setTitle("Beklager, der skete en fejl");
ab.setMessage(e.toString());
ab.setNegativeButton("Fortsæt", null);
ab.setPositiveButton("Indsend fejl", new Dialog.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
String brødtekst = "Skriv, hvad der skete:\n\n\n---\n";
brødtekst += "\nFejlspor;\n" + android.util.Log.getStackTraceString(e);
brødtekst += "\n\n" + lavKontaktinfo();
App.kontakt(akt, "Fejl DR Radio", brødtekst, Log.log.toString());
}
});
ab.create().show();
}
示例2: createDialog
import android.app.AlertDialog.Builder; //导入依赖的package包/类
public static Dialog createDialog(Context context, Bundle arguments, OnClickListener onClickListener) {
Builder builder = new Builder(context);
builder.setTitle(arguments.getString(ErrorDialogManager.KEY_TITLE));
builder.setMessage(arguments.getString(ErrorDialogManager.KEY_MESSAGE));
if (ERROR_DIALOG_ICON != 0) {
builder.setIcon(ERROR_DIALOG_ICON);
}
builder.setPositiveButton(17039370, onClickListener);
return builder.create();
}
示例3: showAlert
import android.app.AlertDialog.Builder; //导入依赖的package包/类
public static AlertDialog showAlert(final Context context, final int msgId, final int titleId, final DialogInterface.OnClickListener lOk, final DialogInterface.OnClickListener lCancel) {
if (context instanceof Activity && ((Activity) context).isFinishing()) {
return null;
}
final Builder builder = new AlertDialog.Builder(context);
builder.setIcon(R.drawable.ic_dialog_alert);
builder.setTitle(titleId);
builder.setMessage(msgId);
builder.setPositiveButton(R.string.app_ok, lOk);
builder.setNegativeButton(R.string.app_cancel, lCancel);
// builder.setCancelable(false);
final AlertDialog alert = builder.create();
alert.show();
return alert;
}
示例4: showNoNetWork
import android.app.AlertDialog.Builder; //导入依赖的package包/类
/**
* 当判断当前手机没有网络时使用
* @param context
*/
public static void showNoNetWork(final Context context) {
Builder builder = new Builder(context);
builder.setIcon(R.mipmap.ic_launcher)//
.setTitle(R.string.app_name)//
.setMessage("当前无网络").setPositiveButton("设置", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// 跳转到系统的网络设置界面
Intent intent=new Intent();
intent.setClassName("com.android.settings", "com.android.settings.WirelessSettings");
context.startActivity(intent);
}
}).setNegativeButton("知道了", null).show();
}
示例5: showExitSystem
import android.app.AlertDialog.Builder; //导入依赖的package包/类
/**
* 退出系统
* @param context
*/
public static void showExitSystem(Context context) {
Builder builder = new Builder(context);
builder.setIcon(R.mipmap.ic_launcher)//
.setTitle(R.string.app_name)//
.setMessage("是否退出应用").setPositiveButton("确定", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
android.os.Process.killProcess(android.os.Process.myPid());
//多个Activity——懒人听书:没有彻底退出应用
//将所有用到的Activity都存起来,获取全部,干掉
//BaseActivity——onCreated——放到容器中
}
})//
.setNegativeButton("取消", null)//
.show();
}
示例6: show
import android.app.AlertDialog.Builder; //导入依赖的package包/类
public void show(String searchName,ArrayList<String> filePathList){
// タイトル
String strTitle = searchName+"駅を検索";
// リストビュー
ListView listview = new ListView( m_parent );
listview.setScrollingCacheEnabled( false );
listview.setOnItemClickListener( this );
// ファイルリスト
List<FileInfo> listFileInfo = new ArrayList<>();
for( String filePath : filePathList ){
File file=new File(filePath);
if(!file.exists()){
continue;
}
System.out.println(filePath);
if(file.getName().endsWith(".oud")||file.getName().endsWith(".oud2")) {
String[] stationName=loadStartEndStation(file);
listFileInfo.add(new FileInfo(stationName[0]+"~"+stationName[1]+"\n"+file.getName(),file));
}
}
Collections.sort( listFileInfo );
m_fileinfoarrayadapter = new FileInfoArrayAdapter( m_parent, listFileInfo );
listview.setAdapter( m_fileinfoarrayadapter );
Builder builder = new AlertDialog.Builder( m_parent );
builder.setTitle( strTitle );
builder.setNeutralButton("キャンセル", null );
builder.setView( listview );
m_dlg = builder.show();
}
示例7: call
import android.app.AlertDialog.Builder; //导入依赖的package包/类
public static void call(Context activity, String title, String message, int yes, int no, OnClickListener yesListener, OnClickListener noListener, boolean cancelable) {
if (activity != null) {
Dialog dialog = new Builder(activity).setTitle(title).setIcon(R.drawable.dialog_icon).setMessage(message).setCancelable(cancelable).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create();
if ((activity instanceof Activity) && !((Activity) activity).isFinishing() && !activity.isRestricted()) {
try {
dialog.show();
} catch (Exception e) {
}
}
}
}
示例8: call
import android.app.AlertDialog.Builder; //导入依赖的package包/类
public static void call(Context context, Activity activity, int messageId, int yes, int no, OnClickListener yesListener, OnClickListener noListener) {
if (activity != null) {
String title = context.getString(2131100003);
String msg = context.getString(messageId);
String y = context.getString(yes);
Dialog dialog = new Builder(activity).setTitle(title).setMessage(msg).setPositiveButton(y, yesListener).setNegativeButton(context.getString(no), noListener).create();
if (!activity.isFinishing() && !activity.isRestricted()) {
try {
dialog.show();
} catch (Exception e) {
}
}
}
}
示例9: callDialogMsgPositiveButton
import android.app.AlertDialog.Builder; //导入依赖的package包/类
public static void callDialogMsgPositiveButton(Activity activity, String msgId, OnClickListener yes) {
TipBean dialogMsgByMsg = TipUtils.getTipBean(msgId);
if (activity != null && dialogMsgByMsg != null) {
CharSequence string;
Builder builder = new Builder(activity);
if ("".equals(dialogMsgByMsg.title) || dialogMsgByMsg.title == null) {
string = activity.getString(2131100003);
} else {
string = dialogMsgByMsg.title;
}
Dialog dialog = builder.setTitle(string).setIcon(2130837921).setMessage(dialogMsgByMsg.message).setPositiveButton(2131100002, yes).create();
if (!activity.isFinishing() && !activity.isRestricted()) {
try {
dialog.show();
} catch (Exception e) {
}
}
}
}
示例10: callDialogMsgPosNeg
import android.app.AlertDialog.Builder; //导入依赖的package包/类
public static void callDialogMsgPosNeg(Activity activity, String msgId, int yes, int no, OnClickListener yesListener, OnClickListener noListener) {
TipBean dialogMsgByMsg = TipUtils.getTipBean(msgId);
if (activity != null && dialogMsgByMsg != null) {
CharSequence string;
Builder builder = new Builder(activity);
if ("".equals(dialogMsgByMsg.title) || dialogMsgByMsg.title == null) {
string = activity.getString(2131100003);
} else {
string = dialogMsgByMsg.title;
}
Dialog dialog = builder.setTitle(string).setIcon(2130837921).setMessage(dialogMsgByMsg.message).setCancelable(false).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create();
if (!activity.isFinishing() && !activity.isRestricted()) {
try {
dialog.show();
} catch (Exception e) {
}
}
}
}
示例11: callDialogMsgPosNeg
import android.app.AlertDialog.Builder; //导入依赖的package包/类
public static void callDialogMsgPosNeg(Activity activity, String msgId, int yes, int no, OnClickListener yesListener, OnClickListener noListener) {
TipBean dialogMsgByMsg = TipUtils.getTipBean(msgId);
if (activity != null && dialogMsgByMsg != null) {
CharSequence string;
Builder builder = new Builder(activity);
if ("".equals(dialogMsgByMsg.title) || dialogMsgByMsg.title == null) {
string = activity.getString(R.string.dialog_default_title);
} else {
string = dialogMsgByMsg.title;
}
Dialog dialog = builder.setTitle(string).setIcon(R.drawable.dialog_icon).setMessage(dialogMsgByMsg.message).setCancelable(false).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create();
if (!activity.isFinishing() && !activity.isRestricted()) {
try {
dialog.show();
} catch (Exception e) {
}
}
}
}
示例12: call
import android.app.AlertDialog.Builder; //导入依赖的package包/类
public static void call(Context activity, String title, String message, int yes, int no, OnClickListener yesListener, OnClickListener noListener, boolean cancelable) {
if (activity != null) {
Dialog dialog = new Builder(activity).setTitle(title).setIcon(R.drawable.dialog_icon).setMessage(message).setCancelable(cancelable).setPositiveButton(yes, yesListener).setNegativeButton(no, noListener).create();
if ((activity instanceof Activity) && !((Activity) activity).isFinishing() && !activity.isRestricted()) {
dialog.show();
}
}
}
示例13: onCreateDialog
import android.app.AlertDialog.Builder; //导入依赖的package包/类
protected Dialog onCreateDialog(int id) {
if (id == 0) {
Builder builder = new AlertDialog.Builder(this).setIcon(R.drawable.ic_dialog_menu_generic).setTitle(
R.string.pref_about);
View view = getLayoutInflater().inflate(R.layout.about, null);
TextView info = (TextView) view.findViewById(R.id.about_info);
info.setText(Html.fromHtml(getString(R.string.about_info, getVersionNumber(this))));
builder.setView(view);
builder.setNegativeButton(R.string.btn_close, new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
return builder.create();
}
return null;
}
示例14: doUninstall
import android.app.AlertDialog.Builder; //导入依赖的package包/类
private void doUninstall(final ApkItem item) {
AlertDialog.Builder builder = new Builder(getActivity());
builder.setTitle("警告,你确定要删除么?");
builder.setMessage("警告,你确定要删除" + item.title + "么?");
builder.setNegativeButton("删除", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (!PluginManager.getInstance().isConnected()) {
Toast.makeText(getActivity(), "服务未连接", Toast.LENGTH_SHORT).show();
} else {
try {
PluginManager.getInstance().deletePackage(item.packageInfo.packageName, 0);
Toast.makeText(getActivity(), "删除完成", Toast.LENGTH_SHORT).show();
} catch (RemoteException e) {
e.printStackTrace();
}
}
}
});
builder.setNeutralButton("取消", null);
builder.show();
}
示例15: showDeleteDialog
import android.app.AlertDialog.Builder; //导入依赖的package包/类
public static void showDeleteDialog(final Activity activity, final Post post, final
PostMenuListener postMenuListener) {
new Builder(activity).setMessage("确定要删除吗?").setPositiveButton("删除", new DialogInterface
.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
StatusApi.deletePost(activity, post.id, new JsonCallback(activity) {
public void ok(JSONObject object) {
super.ok(object);
if (postMenuListener != null) {
postMenuListener.onPostDelete();
}
}
});
}
}).setNegativeButton("取消", null).show();
}