Code example for AlertDialog.Builder

Methods: setItems, setTitle, show

2
		} 
	} 
	 
	protected Dialog onCreateDialog(int id) {
		Dialog dialog = null;
		AlertDialog.Builder builder = new Builder(this);
		 
		switch (id) {
		case DIALOG_LOAD_FILE :
			builder.setTitle("Choose your background");
			if (mFileList == null) {
				Log.e(TAG, "Showing file chooser before loading the file list");
				dialog = builder.create();
				return dialog;
			} 
			builder.setItems(mFileList, new DialogInterface.OnClickListener(){
				public void onClick(DialogInterface dialog, int which){
					mChosenFile = mFileList[which];
					// do other shit with file 
				} 
			}); 
			break; 
		} 
		dialog = builder.show();
		return dialog;
	} 
} 
Contextual code suggestions in your IDE  Get Codota for Java