Code example for AlertDialog.Builder

Methods: setItems, setTitle, show

0
		} 
	} 
 
	private static void displayPrefixDialog(final EditText editText,
			final XmlNode node, final boolean allowXmlns) {
		AlertDialog.Builder builder = new Builder(editText.getContext());
 
		final List<String> prefixes = node.getContent().getNamespacePrefixes();
 
		// add some options 
		Collections.sort(prefixes);
		if (prefixes.contains("xmlns")) {
			prefixes.remove("xmlns");
		} 
		if (allowXmlns) {
			prefixes.add(0, "xmlns");
		} 
		prefixes.add(0, "");
 
		builder.setTitle("Prefix");
		builder.setItems(prefixes.toArray(new String[prefixes.size()]),
				new OnClickListener() {
 
					@Override 
					public void onClick(final DialogInterface dialog,
							final int which) {
						String prefix = prefixes.get(which);
						editText.setText(prefix);
					} 
				}); 
 
		builder.show();
 
	} 
 
	/** 
	 * Ellipsizes a text