WebView loadData - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for WebView loadData method.

This code example shows how to use the following methods:loadData, setLayoutParams, setView
		if (mDialog != null) {
			mDialog.dismiss();
			mDialog = null;
		} 
		AlertDialog.Builder b = new AlertDialog.Builder(c);
		WebView html = new WebView(c);
		html.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
		html.loadData(loadAssetFile(c, c.getString(filenameid)), "text/html", "UTF-8");
		mDialog = b.setIcon(null)
				.setView(html)
				.setPositiveButton("OK", this)
				.show();
	} 
	 
	private String loadAssetFile(Context c, String name) {
		try { 
			BufferedReader r = new BufferedReader(new InputStreamReader(c.getAssets().open(name)));
			StringBuilder sb = new StringBuilder();
			do { 
				String line = r.readLine();
7
CodeRank
This code example shows how to use the following methods:loadData
    /** 
     * Sets up the UI. It consists if a single WebView. 
     */ 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        mWebView = new WebView(getActivity());
        loadWebView(); 
        return mWebView;
    } 
 
    /** 
     * Displays a particular article. 
     * 
     * @param article the article to display 
     */ 
    public void displayArticle(NewsArticle article) {
        mNewsArticle = article;
        loadWebView(); 
    } 
 

6
CodeRank
This code example shows how to use the following methods:loadData, setBackgroundColor, setPictureListener
		 
	} 
	 
	private void delaySetup(){ 
		 
		wv.setPictureListener(new PictureListener() {
			 
 
			@Override 
			public void onNewPicture(WebView view, Picture picture) {
				wv.setPictureListener(null);
				setup(); 
			} 
			 
			 
		}); 
		 
		//wv.setInitialScale(100); 
		wv.loadData("<html></html>", "text/html", "utf-8");
		wv.setBackgroundColor(color);

8
CodeRank
This code example shows how to use the following methods:loadData
 
	@Override 
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		 
		WebView webview = new WebView(this);
		setContentView(webview);
		 
		InputStream in = null;
		try { 
			in = this.openFileInput("error.html");
			 
			if(in != null) {
				IOUtils utils = new IOUtils();
				String read = utils.read(in);
				webview.loadData(read, "text/html", "utf-8");
			} 
			else { 
				webview.loadData("No Error Data!", "text/html", "utf-8");
			} 
		} 
6
CodeRank
This code example shows how to use the following methods:getSettings, loadData, setLayoutParams
		RelativeLayout layout = new RelativeLayout(getActivity());
		layout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
		layout.setMinimumWidth(450);
		 
		// Create the webview. 
		WebView webview = new WebView(getActivity());
		webview.getSettings().setBuiltInZoomControls(true);
		webview.loadData(description, "text/html", null);
		 
		// Set the layout parameters. 
		LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
		webview.setLayoutParams(params);
		 
		// Add the webview. 
		layout.addView(webview);
		return layout;
	} 
	 
	// }}} 
} 
6
CodeRank
This code example shows how to use the following methods:getSettings, loadData, setWebChromeClient
 
	@Override 
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
 
		WebView web = new WebView(this);
 
		WebSettings webSettings = web.getSettings();
		webSettings.setSavePassword(false);
		webSettings.setSaveFormData(false);
		webSettings.setJavaScriptEnabled(true);
		webSettings.setSupportZoom(false);
 
		web.setWebChromeClient(new MyWebChromeClient());
 
		String htmldata = "";//loadResToString(R.raw.help, this);
		 
		web.loadData(htmldata, "text/html", "UTF-8");
		 
		//web.loadUrl("http://www.google.com.br"); 

6
CodeRank
This code example shows how to use the following methods:loadData
public class InfoActivity extends MuseumActivity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WebView wv = new WebView(getApplicationContext());
        wv.loadData(getIntent().getExtras().getString("info"),"text/html","utf-8");
        setContentView(wv);
    } 
} 
6
CodeRank
This code example shows how to use the following methods:addJavascriptInterface, getSettings, loadData, setWebViewClient
        try { 
            runTestOnUiThread(new Runnable() {
                @Override 
                public void run() { 
                    WebView webView = activity.getWebView();
                    webView.addJavascriptInterface(object, name);
                    webView.getSettings().setJavaScriptEnabled(true);
                    webView.setWebViewClient(mWebViewClient);
                    webView.loadData("<!DOCTYPE html><title></title>", "text/html", null);
                } 
            }); 
            mWebViewClient.waitForOnPageFinished();
        } catch (Throwable e) {
            throw new RuntimeException("Failed to set up WebView: " + Log.getStackTraceString(e));
        } 
    } 
 
    protected void executeJavaScript(final String script) throws Throwable {
        runTestOnUiThread(new Runnable() {
            @Override 
6
CodeRank
This code example shows how to use the following methods:loadData
 
    protected void applyBinding() { 
        if (container != null) {
            if (isHtml()) { 
                if (htmlWidget == null) {
                    htmlWidget = new WebView(getRootContext());
                    container.removeAllViews();
                    container.addView(htmlWidget);
                } 
                txtWidget = null;
            } else { 
                if (txtWidget == null) {
                    txtWidget = new TextView(getRootContext());
                    container.removeAllViews();
                    container.addView(txtWidget);
                } 
                htmlWidget = null;
            } 
        } 
        if (txtWidget != null) {

5
CodeRank
This code example shows how to use the following methods:loadData, setBackgroundColor, setPictureListener
		 
	} 
	 
	private void delaySetup(){ 
		 
		wv.setPictureListener(new PictureListener() {
			 
 
			@Override 
			public void onNewPicture(WebView view, Picture picture) {
				wv.setPictureListener(null);
				setup(); 
			} 
			 
			 
		}); 
		 
		//wv.setInitialScale(100); 
		wv.loadData("<html></html>", "text/html", "utf-8");
		wv.setBackgroundColor(color);

6
CodeRank

Related WebView loadData Questions & Answers:

loadData Method Overview
Loads the given data into this WebView using a 'data' scheme URL.
See Code Examples for other Android WebView Methods: