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();}}