load Content To WebView - Android User Interface

Android examples for User Interface:WebView

Description

load Content To WebView

Demo Code


import android.util.Log;
import android.webkit.WebView;
import java.net.URLEncoder;

public class Main{
    public static final String UTF8 = "utf-8";
    public static final String HTML = "text/html";
    private static final String FAKE_URL = "fake://fuck/android";
    public static void loadToWebView(WebView webView, String content) {
        webView.loadDataWithBaseURL(FAKE_URL,
                WebUtils.wrapWithHtml(content), WebUtils.HTML,
                WebUtils.UTF8, "");
    }/*from ww w .  j a  v  a2s  .  co m*/
    public static String wrapWithHtml(String content) {
        return "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /></head><body>"
                + content + "</body></html>";
    }
}

Related Tutorials