Code example for AlertDialog.Builder

Methods: create, setCancelable, setMessage, setNegativeButton, setNeutralButton

0
	} 
  
	protected boolean onTap(int index) {
		final OverlayItem overlayItem = overlayItemList.get(index);
		final GeoPoint selectedPoint = overlayItem.getPoint();
		Builder builder = new AlertDialog.Builder(context);
		builder.setNeutralButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                Intent intent = new Intent(context, setProximityAlertActivity.class);
                 
                CharSequence text = "Stop Selected! Wait for a notification";
                int duration = Toast.LENGTH_LONG;
 
                Toast toast = Toast.makeText(context, text, duration);
                toast.show();
                 
                intent.putExtra("latitude", selectedPoint.getLatitudeE6());
                intent.putExtra("longitude", selectedPoint.getLongitudeE6());
                context.startActivity(intent);
            } 
        }); 
		builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();
            } 
        }); 
		builder.setMessage("Select this Stop?");
		builder.setCancelable(true);
		 
		AlertDialog dialog = builder.create();
		dialog.show();
		return true; 
	}; 
} 
Stop searching for code, let great code find you!  Add Codota to your java IDE