當前位置: 首頁>>代碼示例>>Java>>正文


Java AlertDialog.Builder方法代碼示例

本文整理匯總了Java中android.app.AlertDialog.Builder方法的典型用法代碼示例。如果您正苦於以下問題:Java AlertDialog.Builder方法的具體用法?Java AlertDialog.Builder怎麽用?Java AlertDialog.Builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.AlertDialog的用法示例。


在下文中一共展示了AlertDialog.Builder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createConnection

import android.app.AlertDialog; //導入方法依賴的package包/類
/**
 * Para debug.
 * @param activity
 * @param context
 */
public void createConnection(Activity activity, Context context){
    try{
        dataOpenHelper = new DataOpenHelper(activity);

        connection = dataOpenHelper.getWritableDatabase();

        Toast.makeText(context, "Conexão com o banco bem sucedida", Toast.LENGTH_SHORT).show();
    }
    catch (SQLException e) {
        AlertDialog.Builder alert = new AlertDialog.Builder(activity);
        alert.setTitle(R.string.title_erro);
        alert.setMessage(e.getMessage());
        alert.setNeutralButton("Que Merda!", null);
        alert.show();
    }
}
 
開發者ID:victorvgc,項目名稱:natumassas-app,代碼行數:22,代碼來源:DBConnection.java

示例2: onCreateDialog

import android.app.AlertDialog; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (isBuilder() && getLayoutId() != 0) {
        view = getActivity().getLayoutInflater().inflate(getLayoutId(), null);
    }

    // 綁定ButterKnife
    unbinder = ButterKnife.bind(this, view);

    // 創建AlertDialog
    AlertDialog.Builder dialog = builder();
    if (isBuilder() && getLayoutId() != 0) {
        dialog.setView(view);
    }

    // 拆分係統onCreateDialog方法,提供一個create方法,基本初始化代碼放到onCreateDialog執行,對於子類的初始化放到create方法執行
    this.create(savedInstanceState, view);

    return dialog.create();
}
 
開發者ID:RockyQu,項目名稱:MVVMFrames,代碼行數:21,代碼來源:BaseDialogFragment.java

示例3: ActivateReadMeDialog

import android.app.AlertDialog; //導入方法依賴的package包/類
public void ActivateReadMeDialog(Activity activity , Context context,int Language){
    AlertDialog.Builder mReadMeBuilder = new AlertDialog.Builder(activity);
    final AlertDialog mReadMeDialog =  mReadMeBuilder.create();
    mReadMeDialog.show();
    mReadMeDialog.setContentView(R.layout.read_me_layout);
    mBackButton = (Button)mReadMeDialog.findViewById(R.id.back_buttonOnReadMe);
    TextView mReadMeTextView = (TextView)mReadMeDialog.findViewById(R.id.ReadMeTextView);
    if(Language==0){mReadMeTextView.setText(activity.getResources().getString(R.string.ReadMeGrDialog));}
    else{mReadMeTextView.setText(activity.getResources().getString(R.string.ReadMeEngDialog));}
    mBackButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            mReadMeDialog.cancel();
        }
    });

}
 
開發者ID:JamesNikolaidis,項目名稱:Thesis_Farmers_Helper,代碼行數:18,代碼來源:Read_Me_Dialog.java

示例4: promptForMusicAccess

import android.app.AlertDialog; //導入方法依賴的package包/類
private void promptForMusicAccess() {
    if (alreadyPrompted) return;
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (!prefs.getString("headerStyle2", "Search Bar").equals("Music Controls") &&
            !prefs.getString("city", "San Francisco").equals("Music:music-theme")) {
        return;
    }
    alreadyPrompted = true;
    AlertDialog.Builder d = new AlertDialog.Builder(MainActivity.this);
    d.setTitle("Notification Access Required");
    d.setMessage("SF Launcher requires access to notifications in order to display music info and album art. Please enable it on the next page.");
    d.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            startActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"));
        }
    });
    d.show();
}
 
開發者ID:jathak,項目名稱:sflauncher,代碼行數:20,代碼來源:MainActivity.java

示例5: onCreateDialog

import android.app.AlertDialog; //導入方法依賴的package包/類
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Context context = getActivity();

    final AlertDialog.Builder builder = new AlertDialog.Builder(context)
            .setTitle(getPreference().getDialogTitle())
            .setIcon(getPreference().getDialogIcon())
            .setPositiveButton(getPreference().getPositiveButtonText(), this)
            .setNegativeButton(getPreference().getNegativeButtonText(), this);

    View contentView = onCreateDialogView(context);
    if (contentView != null) {
        onBindDialogView(contentView);
        builder.setView(contentView);
    } else {
        builder.setMessage(getPreference().getDialogMessage());
    }

    this.dialog = builder.create();

    return dialog;
}
 
開發者ID:RikkaApps,項目名稱:FCM-for-Mojo,代碼行數:24,代碼來源:HttpUriPreferenceDialogFragment.java

示例6: onMarkerClick

import android.app.AlertDialog; //導入方法依賴的package包/類
@Override
public boolean onMarkerClick(Marker marker, MapView mapView) {
    CellTowerMarker cellTowerMarker = (CellTowerMarker) marker;
    AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
    dialog.setTitle(cellTowerMarker.getTitle());
    dialog.setView(getInfoContents(cellTowerMarker.getMarkerData()));
    dialog.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            dialogInterface.dismiss();
        }
    });
    dialog.show();

    return true;
}
 
開發者ID:5GSD,項目名稱:AIMSICDL,代碼行數:17,代碼來源:CellTowerMarker.java

示例7: showErrorAlert

import android.app.AlertDialog; //導入方法依賴的package包/類
private void showErrorAlert(String error) {
    if (getParentActivity() == null) {
        return;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
    switch (error) {
        case "USERNAME_INVALID":
            builder.setMessage(LocaleController.getString("LinkInvalid", R.string.LinkInvalid));
            break;
        case "USERNAME_OCCUPIED":
            builder.setMessage(LocaleController.getString("LinkInUse", R.string.LinkInUse));
            break;
        case "USERNAMES_UNAVAILABLE":
            builder.setMessage(LocaleController.getString("FeatureUnavailable", R.string.FeatureUnavailable));
            break;
        default:
            builder.setMessage(LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred));
            break;
    }
    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
    showDialog(builder.create());
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:24,代碼來源:ChannelCreateActivity.java

示例8: showAvisoDialog

import android.app.AlertDialog; //導入方法依賴的package包/類
private void showAvisoDialog() {
    AlertDialog.Builder alert = new AlertDialog.Builder(this, R.style.DialogTheme);
    alert.setTitle("Aviso");
    alert.setMessage("Estás a punto de agregar un producto que este centro de acopio" +
            " necesita, por favor introduce solamente información verídica y confirmada");
    alert.setPositiveButton("Aceptar", null);
    alert.show();
}
 
開發者ID:faviotorres,項目名稱:AcopioMX,代碼行數:9,代碼來源:ActivityAgregar.java

示例9: isNewDayValid

import android.app.AlertDialog; //導入方法依賴的package包/類
/**
 * 
 * @return
 */
private boolean isNewDayValid() {
	// check if the value in form is valid
	String text = newClosingDay.getText().toString();
	String alertMsg = "";
	
	if (text!=null && text.length()>0) {
		// Max day of reference month
		Calendar periodCal = new GregorianCalendar(year, month, 1);
		int maxDay = periodCal.getActualMaximum(Calendar.DAY_OF_MONTH);
		
		int newCD = Integer.parseInt(text);
		
		if (newCD<1 || newCD>maxDay) {
			alertMsg = getString(R.string.alert_invalid_closing_day)+" [1-"+maxDay+"].";
		} else if (newCD==regularClosingDay) {
			alertMsg = getString(R.string.alert_regular_closing_day);
		}
		
	} else {
		// text null - alert user
		alertMsg = getString(R.string.alert_null_closing_day);
	}
	if (alertMsg.length()>0) {
		// Alert message
		Log.w("Alert", alertMsg);
		AlertDialog.Builder dlgAlert  = new AlertDialog.Builder(this);
        dlgAlert.setMessage(alertMsg);
        dlgAlert.setTitle(R.string.closing_day);
        dlgAlert.setPositiveButton(R.string.ok, null);
        dlgAlert.setCancelable(true);
        dlgAlert.create().show();
        return false;
	} else {
		return true;
	}
}
 
開發者ID:tiberiusteng,項目名稱:financisto1-holo,代碼行數:41,代碼來源:CCardStatementClosingDayActivity.java

示例10: dialogBuilder

import android.app.AlertDialog; //導入方法依賴的package包/類
public static AlertDialog.Builder dialogBuilder(Context context, String title, String msg) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    if (msg != null) {
        builder.setMessage(msg);
    }
    if (title != null) {
        builder.setTitle(title);
    }
    return builder;
}
 
開發者ID:BaoBaoJianqiang,項目名稱:CustomListView,代碼行數:11,代碼來源:GoUtil.java

示例11: 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

示例12: onCreateDialog

import android.app.AlertDialog; //導入方法依賴的package包/類
/**
 * Applies the args
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the Builder class for convenient dialog construction
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.DialogStyle);

    // Apply args
    builder.setTitle(title).setSingleChoiceItems(choices, active, onC).setPositiveButton("OK", onC);

    Dialog d = builder.create();
    d.setCanceledOnTouchOutside(false);

    // Create the AlertDialog object and return it
    return d;
}
 
開發者ID:dhbw-timetable,項目名稱:dhbw-timetable-android,代碼行數:18,代碼來源:ListDialog.java

示例13: init

import android.app.AlertDialog; //導入方法依賴的package包/類
/**
 * Attempts to create the scanner.
 *
 * @param context
 * @return true if successful
 */
public boolean init(final Activity context) {
    // New Android M+ permission check requirement.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (context.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION)
                != PackageManager.PERMISSION_GRANTED) {
            final AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setTitle("This app needs coarse location access");
            builder.setMessage("Please grant coarse location access so this app can scan for beacons");
            builder.setPositiveButton(android.R.string.ok, null);
            builder.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    ActivityCompat.requestPermissions(context, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION},
                            PERMISSION_REQUEST_COARSE_LOCATION);
                }
            });
            builder.show();
        }
    }
    BluetoothManager manager = (BluetoothManager) context.getApplicationContext()
            .getSystemService(Context.BLUETOOTH_SERVICE);
    BluetoothAdapter btAdapter = manager.getAdapter();
    if (btAdapter == null) {
        return false;
    } else if (!btAdapter.isEnabled()) {
        Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        context.startActivityForResult(enableBtIntent, mRequestEnableBluetooth);
        return false;
    } else {
        scanner = btAdapter.getBluetoothLeScanner();
    }
    return true;
}
 
開發者ID:etsy,項目名稱:divertsy-client,代碼行數:40,代碼來源:BLEScanner.java

示例14: menu

import android.app.AlertDialog; //導入方法依賴的package包/類
void menu() {
	//Log.v(APP_TAG, "Trying to open menu");
	if (lock) {
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		//builder.setTitle("");
		builder.setMessage(getResources().getString(R.string.type_password));
		final EditText inputBox = new EditText(this);
		inputBox.setInputType(InputType.TYPE_CLASS_TEXT|InputType.TYPE_TEXT_VARIATION_PASSWORD);
		builder.setView(inputBox);
		builder.setPositiveButton(android.R.string.yes, 
			new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				if (inputBox.getText().toString().equals(options.getString(Keys.PASSWORD, ""))) {
					openOptionsMenu();
				} else {
					Toast.makeText(getApplicationContext(), getResources().getString(R.string.wrong_password), Toast.LENGTH_LONG).show();
				}
		} });
		builder.setCancelable(true);
		if (!isFinishing()) {
			builder.show();
		}
	} else {
		openOptionsMenu();
	}
}
 
開發者ID:HenriDellal,項目名稱:emerald,代碼行數:28,代碼來源:Apps.java

示例15: onImageLongClickExtraUrl

import android.app.AlertDialog; //導入方法依賴的package包/類
private void onImageLongClickExtraUrl(final String newUrl) {
	DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
           @Override
           public void onClick(DialogInterface dialog, int which) {
               switch (which) {
                   case DialogInterface.BUTTON_POSITIVE:
                       newTab(newUrl, true);
                       break;

                   case DialogInterface.BUTTON_NEGATIVE:
                       getCurrentWebView().loadUrl(newUrl);
                       break;

                   case DialogInterface.BUTTON_NEUTRAL:
                       if (API > 8) {
                           Utils.downloadFile(mActivity, newUrl,
								getCurrentWebView().getUserAgent(), "attachment", false);
                       }
                       break;
               }
           }
       };

	AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); // dialog
	builder.setTitle(newUrl.replace(Constants.HTTP, ""))
               .setMessage(getResources().getString(R.string.dialog_image))
               .setPositiveButton(getResources().getString(R.string.action_new_tab),
					dialogClickListener)
               .setNegativeButton(getResources().getString(R.string.action_open),
					dialogClickListener)
               .setNeutralButton(getResources().getString(R.string.action_download),
					dialogClickListener).show();
}
 
開發者ID:Louis19910615,項目名稱:youkes_browser,代碼行數:34,代碼來源:BrowserActivity.java


注:本文中的android.app.AlertDialog.Builder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。