Code example for AlertDialog.Builder

Methods: setMessage, setNegativeButton, setPositiveButton, setTitle, setView, show

0
		alert.show();
 
	} 
 
	private void popupForName() { 
		AlertDialog.Builder alert = new AlertDialog.Builder(this);
		alert.setTitle("Add Gameplan");
		alert.setMessage("Type in name of gameplan to add");
		final EditText input = new EditText(this);
		alert.setView(input);
		alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int whichButton) {		
				String newName = input.getText().toString();
				ArrayList<String> newPlays = new ArrayList<String>();
 
				GamePlan newGameplan = new GamePlan();
				newGameplan.setGamePlanName(newName);
				newGameplan.addPlaysToGameplan(newPlays);
				DigPlayDB.getInstance(getBaseContext()).storeGamePlan(newGameplan);
				 
				gameplans.add(newName);
				ArrayAdapter<String>adapter = new ArrayAdapter<String>(gameplanAddContext,android.R.layout.simple_list_item_1,gameplans);
				gameplansSpinner.setAdapter(adapter);
				 
				resetGameplanList(); 
			} 
		}); 
 
		alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int whichButton) {
			} 
		}); 
 
		alert.show();
		 
	} 
 
	public void onItemSelected(AdapterView<?> adapter, View v, int position,long arg3) {
		int index = gameplansSpinner.getSelectedItemPosition();