List of usage examples for android.app AlertDialog setTitle
@Override public void setTitle(CharSequence title)
From source file:com.max2idea.android.fwknop.Fwknop.java
public static void UIAlert(String title, String body, Activity activity) { AlertDialog ad; ad = new AlertDialog.Builder(activity).create(); ad.setTitle(title); ad.setMessage(body);//from w ww. j ava 2s .c om ad.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); ad.show(); }
From source file:com.iStudy.Study.Renren.Util.java
/** * ???UI// w w w. j a v a2 s. co m * * @param context * @param title * @param text */ @SuppressWarnings("deprecation") public static void showAlert(Context context, String title, String text, boolean showOk) { AlertDialog alertDialog = new Builder(context).create(); alertDialog.setTitle(title); alertDialog.setMessage(text); if (showOk) { OnClickListener listener = null; alertDialog.setButton2("", listener); } alertDialog.show(); }
From source file:com.iStudy.Study.Renren.Util.java
/** * ??????/*from w w w .j a v a2 s. co m*/ * * @param activity ?Activity * @param title ? * @param text ? * @param listener ? */ public static void showOptionWindow(Activity activity, String title, String text, OnOptionListener listener) { AlertDialog dialog = new AlertDialog.Builder(activity).create(); if (title != null) { dialog.setTitle(title); } if (text != null) { dialog.setMessage(text); } final OnOptionListener oListener = listener; dialog.setButton(AlertDialog.BUTTON_POSITIVE, activity.getString(R.string.renren_sdk_submit), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { oListener.onOK(); } }); dialog.setButton(AlertDialog.BUTTON_NEGATIVE, activity.getString(R.string.renren_sdk_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { oListener.onCancel(); } }); dialog.show(); }
From source file:com.star.printer.StarPrinter.java
private static void ShowAlert(String Title, String Message) { Builder dialog = new AlertDialog.Builder(mContext); dialog.setNegativeButton("Ok", null); AlertDialog alert = dialog.create(); alert.setTitle(Title); alert.setMessage(Message);//from w w w.java2 s.c o m alert.setCancelable(false); alert.show(); }
From source file:com.star.printer.StarPrinter.java
/** * This function is used to print a java bitmap directly to a portable * printer.//from ww w. jav a 2s . c o m * * @param context * Activity for displaying messages to the user * @param portName * Port name to use for communication. This should be * (TCP:<IPAddress> or BT:<Device pair name>) * @param portSettings * Should be mini, the port settings mini is used for portable * printers * @param res * The resources object containing the image data * @param source * The resource id of the image data * @param maxWidth * The maximum width of the image to print. This is usually the * page width of the printer. If the image exceeds the maximum * width then the image is scaled down. The ratio is maintained. */ public static void PrintBitmapImage(Context context, String portName, String portSettings, Resources res, int source, int maxWidth, boolean compressionEnable, boolean pageModeEnable) { ArrayList<byte[]> commands = new ArrayList<byte[]>(); Bitmap bm = BitmapFactory.decodeResource(res, source); StarBitmap starbitmap = new StarBitmap(bm, false, maxWidth); try { commands.add(starbitmap.getImageEscPosDataForPrinting(compressionEnable, pageModeEnable)); sendCommand(context, portName, portSettings, commands); } catch (StarIOPortException e) { Builder dialog = new AlertDialog.Builder(context); dialog.setNegativeButton("Ok", null); AlertDialog alert = dialog.create(); alert.setTitle("Failure"); alert.setMessage(e.getMessage()); alert.setCancelable(false); alert.show(); } }
From source file:com.star.printer.StarPrinter.java
/** * This function shows how to get the firmware information of a printer * /*from w ww . jav a 2s. c om*/ * @param context * Activity for displaying messages to the user * @param portName * Port name to use for communication. This should be * (TCP:<IPAddress> or BT:<DeviceName> for bluetooth) * @param portSettings * Should be mini, the port settings mini is used for portable * printers */ public static void CheckFirmwareVersion(Context context, String portName, String portSettings) { StarIOPort port = null; try { /* * using StarIOPort3.1.jar (support USB Port) Android OS Version: * upper 2.2 */ port = StarIOPort.getPort(portName, portSettings, 10000, context); /* * using StarIOPort.jar Android OS Version: under 2.1 port = * StarIOPort.getPort(portName, portSettings, 10000); */ // A sleep is used to get time for the socket to completely open try { Thread.sleep(500); } catch (InterruptedException e) { } Map<String, String> firmware = port.getFirmwareInformation(); String modelName = firmware.get("ModelName"); String firmwareVersion = firmware.get("FirmwareVersion"); String message = "Model Name:" + modelName; message += "\nFirmware Version:" + firmwareVersion; Builder dialog = new AlertDialog.Builder(context); dialog.setNegativeButton("Ok", null); AlertDialog alert = dialog.create(); alert.setTitle("Firmware Information"); alert.setMessage(message); alert.setCancelable(false); alert.show(); } catch (StarIOPortException e) { Builder dialog = new AlertDialog.Builder(context); dialog.setNegativeButton("Ok", null); AlertDialog alert = dialog.create(); alert.setTitle("Failure"); alert.setMessage("Failed to connect to printer"); alert.setCancelable(false); alert.show(); } finally { if (port != null) { try { StarIOPort.releasePort(port); } catch (StarIOPortException e) { } } } }
From source file:com.star.printer.StarPrinter.java
/** * This function shows how to get the status of a printer * /* www . j a v a2s. c om*/ * @param context * Activity for displaying messages to the user * @param portName * Port name to use for communication. This should be * (TCP:<IPAddress> or BT:<DeviceName> for bluetooth) * @param portSettings * Should be mini, the port settings mini is used for portable * printers */ // portSettings = "mini"; // String portName = BT:<DeviceName>; // context = this public static void CheckStatus(Context context, String portName, String portSettings) { StarIOPort port = null; try { /* * using StarIOPort3.1.jar (support USB Port) Android OS Version: * upper 2.2 */ port = StarIOPort.getPort(portName, portSettings, 10000, context); /* * using StarIOPort.jar Android OS Version: under 2.1 port = * StarIOPort.getPort(portName, portSettings, 10000); */ // A sleep is used to get time for the socket to completely open try { Thread.sleep(500); } catch (InterruptedException e) { } StarPrinterStatus status = port.retreiveStatus(); if (status.offline == false) { Builder dialog = new AlertDialog.Builder(context); dialog.setNegativeButton("Ok", null); AlertDialog alert = dialog.create(); alert.setTitle("Printer"); alert.setMessage("Printer is Online"); alert.setCancelable(false); alert.show(); } else { String message = "Printer is offline"; if (status.receiptPaperEmpty == true) { message += "\nPaper is Empty"; } if (status.coverOpen == true) { message += "\nCover is Open"; } Builder dialog = new AlertDialog.Builder(context); dialog.setNegativeButton("Ok", null); AlertDialog alert = dialog.create(); alert.setTitle("Printer"); alert.setMessage(message); alert.setCancelable(false); alert.show(); } } catch (StarIOPortException e) { Builder dialog = new AlertDialog.Builder(context); dialog.setNegativeButton("Ok", null); AlertDialog alert = dialog.create(); alert.setTitle("Failure"); alert.setMessage("Failed to connect to printer"); alert.setCancelable(false); alert.show(); } finally { if (port != null) { try { StarIOPort.releasePort(port); } catch (StarIOPortException e) { } } } }
From source file:com.star.printer.StarPrinter.java
private static boolean sendCommand(Context context, String portName, String portSettings, ArrayList<byte[]> byteList) { boolean result = true; StarIOPort port = null;/* w w w . jav a 2 s .c om*/ try { /* * using StarIOPort3.1.jar (support USB Port) Android OS Version: * upper 2.2 */ port = StarIOPort.getPort(portName, portSettings, 20000, context); /* * using StarIOPort.jar Android OS Version: under 2.1 port = * StarIOPort.getPort(portName, portSettings, 10000); */ try { Thread.sleep(500); } catch (InterruptedException e) { } /* * Portable Printer Firmware Version 2.4 later, SM-S220i(Firmware * Version 2.0 later) Using Begin / End Checked Block method for * preventing "data detective". When sending large amounts of raster * data, use Begin / End Checked Block method and adjust the value * in the timeout in the "StarIOPort.getPort" in order to prevent * "timeout" of the "endCheckedBlock method" while a printing. If * receipt print is success but timeout error occurs(Show message * which is * "There was no response of the printer within the timeout period." * ), need to change value of timeout more longer in * "StarIOPort.getPort" method. (e.g.) 10000 -> 30000When use * "Begin / End Checked Block Sample Code", do comment out * "query commands Sample code". */ /* Start of Begin / End Checked Block Sample code */ StarPrinterStatus status = port.beginCheckedBlock(); if (true == status.offline) { throw new StarIOPortException("A printer is offline"); } byte[] commandToSendToPrinter = convertFromListByteArrayTobyteArray(byteList); port.writePort(commandToSendToPrinter, 0, commandToSendToPrinter.length); port.setEndCheckedBlockTimeoutMillis(30000);// Change the timeout // time of // endCheckedBlock // method. status = port.endCheckedBlock(); if (true == status.coverOpen) { throw new StarIOPortException("Printer cover is open"); } else if (true == status.receiptPaperEmpty) { throw new StarIOPortException("Receipt paper is empty"); } else if (true == status.offline) { throw new StarIOPortException("Printer is offline"); } /* End of Begin / End Checked Block Sample code */ /* * Portable Printer Firmware Version 2.3 earlier Using query * commands for preventing "data detective". When sending large * amounts of raster data, send query commands after writePort data * for confirming the end of printing and adjust the value in the * timeout in the "checkPrinterSendToComplete" method in order to * prevent "timeout" of the "sending query commands" while a * printing. If receipt print is success but timeout error * occurs(Show message which is * "There was no response of the printer within the timeout period." * ), need to change value of timeout more longer in * "checkPrinterSendToComplete" method. (e.g.) 10000 -> 30000When * use "query commands Sample code", do comment out * "Begin / End Checked Block Sample Code". */ /* Start of query commands Sample code */ // byte[] commandToSendToPrinter = // convertFromListByteArrayTobyteArray(byteList); // port.writePort(commandToSendToPrinter, 0, // commandToSendToPrinter.length); // // checkPrinterSendToComplete(port); /* End of query commands Sample code */ } catch (StarIOPortException e) { result = false; Builder dialog = new AlertDialog.Builder(context); dialog.setNegativeButton("Ok", null); AlertDialog alert = dialog.create(); alert.setTitle("Failure"); alert.setMessage(e.getMessage()); alert.setCancelable(false); alert.show(); } finally { if (port != null) { try { StarIOPort.releasePort(port); } catch (StarIOPortException e) { } } } return result; }
From source file:com.github.mobile.ui.ConfirmDialogFragment.java
public Dialog onCreateDialog(final Bundle savedInstanceState) { AlertDialog dialog = LightAlertDialog.create(getActivity()); dialog.setTitle(getTitle()); dialog.setMessage(getMessage());//from w w w . j a v a 2 s . c o m dialog.setButton(BUTTON_POSITIVE, getResources().getString(android.R.string.yes), this); dialog.setButton(BUTTON_NEGATIVE, getResources().getString(android.R.string.no), this); dialog.setCancelable(true); dialog.setOnCancelListener(this); return dialog; }
From source file:com.jonathongrigg.apps.spark.MainActivity.java
public void showAboutDialog() { final AlertDialog aboutDialog = new AlertDialog.Builder(this).create(); aboutDialog.setTitle(this.getText(R.string.dialog_title)); aboutDialog.setMessage(this.getText(R.string.dialog_text)); aboutDialog.setIcon(R.drawable.ic_menu_info_details); aboutDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { aboutDialog.dismiss();// ww w. j a v a 2 s . c o m } }); aboutDialog.show(); }