List of usage examples for android.app AlertDialog.Builder setTitle
@Override public void setTitle(CharSequence title)
From source file:com.anhuioss.crowdroid.activity.MoreFunctionActivity.java
private void confirmLogoutDialog() { AlertDialog.Builder dlg = new AlertDialog.Builder(this); dlg.setTitle(R.string.logout); dlg.setMessage(getResources().getString(R.string.wheter_to_logout)) .setPositiveButton(getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { @Override//from w ww . j a va2 s. co m public void onClick(DialogInterface dialog, int which) { // NotificationManager notificationManager = (NotificationManager) getSystemService( NOTIFICATION_SERVICE); notificationManager.cancelAll(); Intent i = new Intent(MoreFunctionActivity.this, LoginActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.putExtra("autoLogin", false); startActivity(i); // android.os.Process // .killProcess(android.os.Process.myPid()); } }).setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }) .create().show(); }
From source file:de.evilbrain.sendtosftp.Main.java
public String serverListGetActive() { // Get selected Radio Button int selectedId = serverList.getCheckedRadioButtonId(); // Get text from radio-button RadioButton actualradioButton = (RadioButton) findViewById(selectedId); if (actualradioButton == null) { AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this); dlgAlert.setTitle("Select an Server"); dlgAlert.setMessage("Please select an server from the list"); dlgAlert.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { }/*from w ww .ja v a 2s . co m*/ }); dlgAlert.setCancelable(true); dlgAlert.create().show(); return null; } return actualradioButton.getText().toString(); }
From source file:com.example.android.rowanparkingpass.Activities.CreateVehicleActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Intent myIntent;/*w ww . j ava 2s . com*/ switch (item.getItemId()) { // action with ID action_delete was selected case R.id.action_delete: AlertDialog.Builder alertDialog = new AlertDialog.Builder(CreateVehicleActivity.this); alertDialog.setTitle("Delete Driver?"); alertDialog.setMessage(vehicle.getCarInfo()); alertDialog.setPositiveButton("Delete", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent myIntent = new Intent(CreateVehicleActivity.this, VehiclesActivity.class); myIntent.putExtra(MODE, mode.VEHICLES_LIST.name()); if (SaveData.getSync()) { SendInfoVehicle s = new SendInfoVehicle(); s.deleteVehicle(String.valueOf(vehicle.getVehicleId())); } // delete driver from database db.deleteVehicle(String.valueOf(vehicle.getVehicleId())); new DatabaseHandlerPasses(context) .deleteRequestVehicleID(String.valueOf(vehicle.getVehicleId())); startActivity(myIntent); finish(); } }); alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Do nothing } }); alertDialog.show(); break; default: break; } return true; }
From source file:com.microsoft.windowsazure.messaging.e2etestapp.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_settings: startActivity(new Intent(this, NotificationHubsPreferenceActivity.class)); return true; case R.id.menu_run_tests: if (ApplicationContext.getNotificationHubEndpoint().trim().equals("") || ApplicationContext.getNotificationHubKeyName().trim().equals("") || ApplicationContext.getNotificationHubKeyValue().trim().equals("") || ApplicationContext.getNotificationHubName().trim().equals("")) { startActivity(new Intent(this, NotificationHubsPreferenceActivity.class)); } else {//from w ww . ja va2 s. co m runTests(); } return true; case R.id.menu_check_all: changeCheckAllTests(true); return true; case R.id.menu_uncheck_all: changeCheckAllTests(false); return true; case R.id.menu_reset: refreshTestGroupsAndLog(); return true; case R.id.menu_view_log: AlertDialog.Builder logDialogBuilder = new AlertDialog.Builder(this); logDialogBuilder.setTitle("Log"); final WebView webView = new WebView(this); String logContent = TextUtils.htmlEncode(mLog.toString()).replace("\n", "<br />"); String logHtml = "<html><body><pre>" + logContent + "</pre></body></html>"; webView.loadData(logHtml, "text/html", "utf-8"); logDialogBuilder.setPositiveButton("Copy", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clipboardManager.setText(mLog.toString()); } }); final String postContent = mLog.toString(); logDialogBuilder.setNeutralButton("Post data", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { try { String url = ApplicationContext.getLogPostURL(); if (url != null && url.trim() != "") { url = url + "?platform=android"; HttpPost post = new HttpPost(); post.setEntity(new StringEntity(postContent, "utf-8")); post.setURI(new URI(url)); new DefaultHttpClient().execute(post); } } catch (Exception e) { // Wasn't able to post the data. Do nothing } return null; } }.execute(); } }); logDialogBuilder.setView(webView); logDialogBuilder.create().show(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:ota.otaupdates.MainActivity.java
private void allow_write_sd() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.write_access)); builder.setMessage(getString(R.string.write_access_message)); builder.setPositiveButton(getString(R.string.button_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (Build.VERSION.SDK_INT >= 23 && !checkPermission()) { // If user hasn't allowed yet, request the permission. requestPermission();//w w w . ja v a 2s .co m } } }); AlertDialog alert = builder.create(); alert.setCancelable(false); if (!checkPermission()) { // If user hasn't allowed yet, show requester dialog. alert.show(); } }
From source file:com.metaphyze.hackernewsfrontpage.HackerNewsFrontPageActivity.java
private void showError(String title, String error) { AlertDialog.Builder builder = new AlertDialog.Builder(HackerNewsFrontPageActivity.this); builder.setTitle(title); builder.setMessage(error);// www . java 2 s . co m builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); }
From source file:com.nuvolect.securesuite.data.SqlSyncTest.java
public void pingPongConfirmDiag(final Activity act) { m_act = act;//from w w w .ja va2s. co m if (!WebUtil.companionServerAssigned()) { Toast.makeText(act, "Configure companion device for test to operate", Toast.LENGTH_LONG).show(); return; } String title = "Pyramid comm test with companion device"; String message = "This is a non-destructive network performance test. " + "Payload size is incrementally increased."; AlertDialog.Builder builder = new AlertDialog.Builder(act); builder.setTitle(title); builder.setMessage(Html.fromHtml(message)); builder.setIcon(CConst.SMALL_ICON); builder.setCancelable(true); builder.setPositiveButton("Start test", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { setProgressCallback(m_act, pingPongCallbacks); pingPongProgress(act); SqlSyncTest.getInstance().init();// Small amount of init on UI thread WorkerCommand.quePingTest(m_act);// Heavy lifting on non-UI thread } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog_alert.cancel(); } }); dialog_alert = builder.create(); dialog_alert.show(); // Activate the HTML TextView tv = ((TextView) dialog_alert.findViewById(android.R.id.message)); tv.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:dtu.ds.warnme.app.dialog.ReportDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_report, null); builder.setView(view);//from w w w . ja va2 s . c o m builder.setTitle(R.string.report); builder.setPositiveButton(R.string.report, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int which) { // Nothing do to here } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int which) { // Nothing do to here } }); progressView = view.findViewById(R.id.dialog_report_progress); formView = view.findViewById(R.id.dialog_report_form); accidentRdBtn = (RadioButton) view.findViewById(R.id.dialog_report_form_radio_button_event_type_accident); policeRdBtn = (RadioButton) view.findViewById(R.id.dialog_report_form_radio_button_event_type_police); speedCameraRdBtn = (RadioButton) view .findViewById(R.id.dialog_report_form_radio_button_event_type_speed_camera); noteEditText = (EditText) view.findViewById(R.id.dialog_report_form_edit_text_note); dialog = builder.create(); dialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialogInterface) { final Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE); positiveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String note = noteEditText.getText().toString(); Location location = (Location) getArguments().get(MainActivity.KEY_CURRENT_LOCATION); Event event = new Event(); event.setEventType(getEventType()); event.setLatitude(location.getLatitude()); event.setLongitude(location.getLongitude()); event.setBearing((180 + location.getBearing()) % 360); event.setNote(note); RestClientHolder.getRestClient().addEvent(dialog.getContext(), event, new AsyncHttpResponseHandler() { @Override public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { Log.e(TAG, "Reporting failed. [statusCode = " + statusCode + ", error=" + error + "]"); listener.onReportFailed(); Toast.makeText(dialog.getContext(), R.string.report_failed, Toast.LENGTH_LONG).show(); } @Override public void onFinish() { positiveButton.setEnabled(true); UiUtilities.fadeInFadeOut(formView, progressView); } @Override public void onStart() { positiveButton.setEnabled(false); UiUtilities.fadeInFadeOut(progressView, formView); } @Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { Log.i(TAG, "Reporting successful. [statusCode = " + statusCode + "]"); dialog.dismiss(); listener.onReportSuccessful(); } }); } }); final Button negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE); negativeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { RestClientHolder.getRestClient().cancelRequests(dialog.getOwnerActivity(), true); dialog.dismiss(); listener.onAbort(); } }); } }); return dialog; }
From source file:com.honeycomb.cocos2dx.Soccer.java
public void quitGame(JSONObject prms) { AlertDialog.Builder exitbuilder = new AlertDialog.Builder(this); exitbuilder.setTitle("Girl Superhero").setMessage(com.honeycomb.cocos2dx.R.string.QUIT_MESSAGE) .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { AndroidNDKHelper.SendMessageWithParameters("resetListener", getDict()); }// ww w.j av a 2 s . co m }).setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog stopalert = exitbuilder.create(); stopalert.show(); }
From source file:com.njlabs.amrita.aid.landing.Landing.java
private void setupGrid() { GridView gridView = (GridView) findViewById(R.id.landing_grid); gridView.setAdapter(new LandingAdapter(baseContext)); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override/*from www . j a v a 2 s . c om*/ public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { String name = ((TextView) view.getTag(R.id.landing_text)).getText().toString(); switch (name) { case "About Amrita": // ABOUT AMRITA startActivity(new Intent(baseContext, Amrita.class)); break; case "Announcements": Snackbar.make(parentView, "Announcements is under construction", Snackbar.LENGTH_SHORT).show(); break; case "Academic Calender": // ACADEMIC CALENDER startActivity(new Intent(baseContext, Calender.class)); break; case "Amrita UMS Login": // AUMS startActivity(new Intent(baseContext, AumsActivity.class)); break; case "Train & Bus Timings": // TRAIN & BUS INFO final CharSequence[] transportationOptions = { "Trains from Coimbatore", "Trains from Palghat", "Trains to Coimbatore", "Trains to Palghat", "Buses from Coimbatore", "Buses to Coimbatore" }; AlertDialog.Builder transportationDialogBuilder = new AlertDialog.Builder(baseContext); transportationDialogBuilder.setTitle("View timings of ?"); transportationDialogBuilder.setItems(transportationOptions, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { // Showing Alert Message Intent trainBusOpen = new Intent(baseContext, TrainBusInfo.class); trainBusOpen.putExtra("type", transportationOptions[item]); startActivity(trainBusOpen); } }); AlertDialog transportationDialog = transportationDialogBuilder.create(); transportationDialog.show(); break; case "GPMS Login": // GPMS LOGIN startActivity(new Intent(baseContext, GpmsActivity.class)); break; case "Curriculum Info": // CURRICULUM INFO final CharSequence[] items_c = { "Aerospace Engineering", "Civil Engineering", "Chemical Engineering", "Computer Science Engineering", "Electrical & Electronics Engineering", "Electronics & Communication Engineering", "Electronics & Instrumentation Engineering", "Mechanical Engineering" }; AlertDialog.Builder departmentDialogBuilder = new AlertDialog.Builder(baseContext); departmentDialogBuilder.setTitle("Select your Department"); departmentDialogBuilder.setItems(items_c, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { // Showing Alert Message Intent curriculum_open = new Intent(baseContext, Curriculum.class); curriculum_open.putExtra("department", items_c[item]); startActivity(curriculum_open); } }); AlertDialog departmentDialog = departmentDialogBuilder.create(); departmentDialog.show(); break; case "News": // NEWS startActivity(new Intent(baseContext, NewsActivity.class)); break; default: Toast.makeText(baseContext, String.valueOf(i), Toast.LENGTH_SHORT).show(); } } }); }