Android-how to bring up the dialog box

Source: Internet
Author: User
Tags polyline

Click the button to display the dialog box and call the code:

// Select the image: ploygon, line, pointpublic void selectgeometry (view) {showdialog (0 );}

Showdialog is a method of activity. This method displays the oncreatedialog method definition dialog box.

The oncreatedialog method is defined as follows:

protected Dialog onCreateDialog(int id) {return new AlertDialog.Builder(this).setTitle("Select Geometry").setItems(geometryTypes, new DialogInterfaceClickListener()).create();}

The dialoginterfaceclicklistener class is defined as follows:

class DialogInterfaceClickListener implements DialogInterface.OnClickListener{@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stubgraphicsLayer.removeAll();// ignore first elementToast toast = Toast.makeText(getApplicationContext(),"", Toast.LENGTH_LONG);toast.setGravity(Gravity.BOTTOM, 0, 0);// Get item selected by user.String geomType = geometryTypes[which];lblMsg.setText(geomType + " selected.");selectedGeometryIndex = which;// process user selectionif (geomType.equalsIgnoreCase("Polygon")) {myListener.setType("POLYGON");toast.setText("Drag finger across screen to draw a Polygon. \nRelease finger to stop drawing.");} else if (geomType.equalsIgnoreCase("Polyline")) {myListener.setType("POLYLINE");toast.setText("Drag finger across screen to draw a Polyline. \nRelease finger to stop drawing.");} else if (geomType.equalsIgnoreCase("Point")) {myListener.setType("POINT");toast.setText("Tap on screen once to draw a Point.");}toast.show();}}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.