Android examples for User Interface:Alert Dialog
show Alert using WebView
import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.view.ViewGroup.LayoutParams; import android.webkit.WebView; public class Main { static public void showAlert(Context ctx, final String message, boolean html) { AlertDialog alertDialog = new AlertDialog.Builder(ctx).create(); alertDialog.setTitle("Info"); if (!html)/* w w w . j a v a 2s .c o m*/ alertDialog.setMessage(message); else { WebView vView = new WebView(ctx); vView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); vView.loadData(message, "text/html", "UTF-8"); alertDialog.setView(vView); } alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "Dismiss", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Do nothing } }); alertDialog.show(); } }