Android.App.Dialog

I found amusing how can you use Webkit to display, almost any HTML code on Android.
This is a snippet you my add as part of your onCreate(…) method.

WebView wv = new WebView(this);
String str = ” Your own html code here! “;
wv.loadData(str, “text/html”, “utf-8”);
Dialog dialog = new Dialog(this) {

public boolean onKeyDown(int keyCode, KeyEvent event){
if (keyCode != KeyEvent.KEYCODE_DPAD_LEFT)
this.dismiss();
return true;
}
};

Once you created your content and added your code to the OnCreate() method, it’s worth to show your Dialog, by adding the Content View into the Dialog object created.

dialog.addContentView(wv, new LinearLayout.LayoutParams(100, 100));
dialog.show();

You may though, create your own Layout using layout/yourlayout.xml
but for now this is a simple snippet of what you can do with Android.

Leave a Reply

Visit Us On TwitterVisit Us On FacebookVisit Us On YoutubeVisit Us On Linkedin