本文整理匯總了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();
}