List of usage examples for android.app AlertDialog.Builder show
public void show()
From source file:mp.paschalis.RequestActivity.java
/** * Returns a book to user//w w w . ja v a 2 s. com */ private void hButtonReturnBook() { buttonHybrid.setText(R.string.isItReturned_); buttonHybrid.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { { AlertDialog.Builder alert = new AlertDialog.Builder(RequestActivity.this); alert.setTitle(R.string.msgIsItReturnedToYou_); alert.setIcon(R.drawable.ic_menu_forward); alert.setNegativeButton(R.string.no, new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); alert.setPositiveButton(R.string.yes, new android.content.DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Return the book new AsyncTaskReturnABook().execute(dataClassActivities.book.isbn); } }); alert.show(); } // DataClassLentABook data = new DataClassLentABook(); // // data.destinationUser = dataClassActivities.username; // data.isbn = dataClassActivities.isbn; // // new AsyncTaskLentABook_Activities().execute(data); } }); }
From source file:com.sssemil.sonyirremote.ir.ir.java
public void alert(String msg) { AlertDialog.Builder errorD = new AlertDialog.Builder(this); errorD.setTitle(getString(R.string.error)); errorD.setMessage(msg);/*from w ww .ja v a2 s . com*/ errorD.setIcon(android.R.drawable.ic_dialog_alert); errorD.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); errorD.show(); }
From source file:com.example.drugsformarinemammals.Dose_Information.java
private void displayMessage(String messageTitle, String message) { AlertDialog.Builder myalert = new AlertDialog.Builder(this); TextView title = new TextView(this); title.setTypeface(Typeface.SANS_SERIF); title.setTextSize(20);//from w ww .j av a2 s .co m title.setTextColor(getResources().getColor(R.color.blue)); title.setPadding(8, 8, 8, 8); title.setText("Synchronization"); title.setGravity(Gravity.CENTER_VERTICAL); LinearLayout layout = new LinearLayout(this); TextView text = new TextView(this); text.setTypeface(Typeface.SANS_SERIF); text.setTextSize(20); text.setPadding(10, 10, 10, 10); text.setText(message); layout.addView(text); myalert.setView(layout); myalert.setCustomTitle(title); myalert.setCancelable(true); myalert.show(); }
From source file:com.example.run_tracker.ProfileFragment.java
@Override public void onClick(View arg0) { Log.v(TAG, "click"); AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle("Enter Password"); alert.setMessage("Please enter your password"); // Set an EditText view to get user input final EditText input = new EditText(getActivity()); input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); alert.setView(input);// ww w . ja v a2 s. c o m alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String password = input.getText().toString(); String new_password = null; if (!mPassword1.getText().toString().equals(mPassword2.getText().toString())) { Toast.makeText(getActivity(), "Passwords dont match", Toast.LENGTH_LONG).show(); } else { if (isEmpty(mPassword1) || (isEmpty(mPassword2))) { new_password = password; } else { new_password = mPassword1.getText().toString(); } Make_edit_profile_request(password, new_password); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); }
From source file:cc.echonet.coolmicapp.MainActivity.java
@Override public void onBackPressed() { // Write your code here if (isThreadOn) { AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this); alertDialog.setTitle("Stop Broadcasting?"); alertDialog.setMessage("Tap [ Ok ] to stop broadcasting."); alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { backyes = false;/*from ww w .j av a2s . c om*/ dialog.cancel(); } }); alertDialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { backyes = true; dialog.cancel(); invalidateOptionsMenu(); start_button.clearAnimation(); start_button.setBackground(buttonColor); start_button.setText(R.string.start_broadcast); ClearLED(); android.os.Process.killProcess(android.os.Process.myPid()); } }); alertDialog.show(); } else { android.os.Process.killProcess(android.os.Process.myPid()); } }
From source file:tm.veriloft.mapsplayground.MapsActivity.java
/** * This is where we can add markers or lines, add listeners or move the camera. In this case, we * just add a marker near Africa./*from w ww . j a va 2 s .c om*/ * <p> * This should only be called once and when we are sure that {@link #mMap} is not null. */ private void setUpMap() { mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID); mMap.setMyLocationEnabled(true); mMap.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() { @Override public void onMapLongClick(final LatLng latLng) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MapsActivity.this); alertDialogBuilder.setTitle("Confirm Route Drawing"); alertDialogBuilder.setMultiChoiceItems(drawOptionsStrings, drawOptionsValues, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { drawOptionsValues[which] = isChecked; setDrawOptionsValues(); } }); alertDialogBuilder.setNegativeButton("Nope", null); alertDialogBuilder.setPositiveButton("Yes, of coz", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Location location = mMap.getMyLocation(); if (location != null) { fetchAndDrawRoute(new LatLng(location.getLatitude(), location.getLongitude()), latLng); } else { showCenteredToast("Your current location currently not available, please wait."); } } }); alertDialogBuilder.show(); } }); mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() { @Override public void onMapClick(LatLng latLng) { l("onMapClick, " + latLng.toString()); } }); focusTo(new LatLng(37.945958662069174, 58.38305085897446), 13); // focus to ashgabat }
From source file:tm.veriloft.mapsplayground.MapsActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.map_routes_clear: //clear them from map for (Polyline drawnRoute : drawnRoutes) drawnRoute.remove();// w w w. j a v a 2 s . c om for (Marker marker : addedMarkers) marker.remove(); //clear array drawnRoutes.clear(); addedMarkers.clear(); break; case R.id.map_type: AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MapsActivity.this); alertDialogBuilder.setTitle("Choose map type"); alertDialogBuilder.setSingleChoiceItems(mapTypeStrings, lastMapType, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); if (which == lastMapType) return; lastMapType = which; switch (which) { case 0: mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); break; case 1: mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID); break; case 2: mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE); break; case 3: mMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN); break; } } }); alertDialogBuilder.setNegativeButton("Cancel", null); alertDialogBuilder.show(); break; } return true; }
From source file:com.sssemil.sonyirremote.ir.ir.java
public void onAddDeviceClick(View paramView) { try {// w ww .j a v a2 s. c om itemN = ((EditText) findViewById(R.id.editText)); brandN = ((EditText) findViewById(R.id.editText2)); if (itemN.getText() != null || brandN.getText() != null) { String all = brandN.getText().toString() + "-" + itemN.getText().toString(); if (!all.equals("-")) { File localFile2 = new File( irpath + brandN.getText().toString() + "-" + itemN.getText().toString()); if (!localFile2.isDirectory()) { localFile2.mkdirs(); } prepItemBrandArray(); } } else { throw new NullPointerException(); } } catch (NullPointerException ex) { AlertDialog.Builder adb = new AlertDialog.Builder(this); adb.setTitle(getString(R.string.error)); adb.setMessage(getString(R.string.you_need_to_select)); adb.setIcon(android.R.drawable.ic_dialog_alert); adb.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { } }); adb.show(); } }
From source file:com.ccxt.whl.activity.SettingsFragmentCopy.java
/** * /*from w w w .j av a 2 s .c o m*/ */ public void change_sex() { AlertDialog.Builder builder = new Builder(getActivity()); String[] strarr = { "", "" }; builder.setItems(strarr, new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { String sex = "2"; // TODO ? if (arg1 == 0) {// sex = "1"; } else {// sex = "2"; } RequestParams params = new RequestParams(); params.add("user", DemoApplication.getInstance().getUser()); params.add("sex", sex); params.add("param", "sex"); HttpRestClient.get(Constant.UPDATE_USER_URL, params, responseHandler); } }); builder.show(); }
From source file:ca.mimic.apphangar.Settings.java
protected void launchDonate() { final Donate donate = new Donate(this); donate.bindServiceConn();/*from w ww. j ava2s .c om*/ View mDonate = donate.getView(mContext); mDonate.refreshDrawableState(); AlertDialog.Builder builder = new AlertDialog.Builder(Settings.this).setTitle(R.string.donate_title) .setIcon(R.drawable.ic_logo).setView(mDonate) .setPositiveButton(R.string.donate_accept_button, null); AlertDialog alert = builder.show(); alert.setOnDismissListener(new AlertDialog.OnDismissListener() { public void onDismiss(DialogInterface dialog) { donate.unbindServiceConn(); } }); donate.setAlert(alert); }