Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4083652
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:20:24+00:00 2026-05-20T18:20:24+00:00

I want to load a HTML form into webview however it is not working

  • 0

I want to load a HTML form into webview however it is not working for me and Im wondering if its even possible? This is the code I have.
Thanks

       package com.timetable;

    import java.io.IOException;

    import org.jsoup.Jsoup;
    import org.jsoup.nodes.Document;
    import org.jsoup.nodes.Element;
    import org.jsoup.select.Elements;

    import android.app.Activity;
    import android.os.Bundle;
    import android.view.KeyEvent;
    import android.view.Window;
    import android.webkit.WebChromeClient;
    import android.webkit.WebView;
    import android.webkit.WebViewClient;

    public class Timetable extends Activity {
        WebView mWebView;
        String html = "<html><body>";
        Document docs;

        public void main(String... args) {

            try {
                 docs = Jsoup.connect("http://www.dcu.ie/timetables/search.shtml").get();
            } catch (IOException e) {
            e.printStackTrace();
        }

        Element table = docs.tagName("header-search");
        Elements tables = table.select("form");

        for (int i = 1; i < tables.size(); i ++) 
        {
            html += tables.get(i).toString() ;
            /*while (tables.get(i).text() == "")
            i++;
            html += "<tr>" + tables.get(i).toString();
            while (tables.get(i+1).text() == "")
            i++;
            html +=tables.get(i+1).toString() + "</tr>";
            i++;*/
        }

        html += "</html></body>";

    }

    public void onCreate(Bundle savedInstanceState) {
        main(); 

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
        mWebView = (WebView) findViewById(R.id.webview);
        mWebView.setWebViewClient(new TimeClient());

        mWebView.setInitialScale(1);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.getSettings().setDomStorageEnabled(true);
        mWebView.loadData(html, "text/html", "utf-8");

        final Activity MyActivity = this;
        mWebView.setWebChromeClient(new WebChromeClient() {
         public void onProgressChanged(WebView view, int progress)  
         {
          //Make the bar disappear after URL is loaded, and changes string to Loading...
          MyActivity.setTitle("Loading...");
          MyActivity.setProgress(progress * 100); //Make the bar disappear after URL is loaded

          // Return the app name after finish loading
             if(progress == 100)
                MyActivity.setTitle(R.string.app_name);
           }
         });
    }

    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
            mWebView.goBack();            
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
    private class TimeClient extends WebViewClient {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {

            view.loadUrl(url);




            return true;
        }
    }


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:20:25+00:00Added an answer on May 20, 2026 at 6:20 pm

    also
    don’t do this : final Activity MyActivity = this;
    instead use “MyActivity.this” inside WebChromeClient.onProgressChanged

    also there is a gotcha with webView you cant do “loadData(data,mime,enc)” for some reason you need to use :
    web.loadDataWithBaseURL(“fake://host/path”,htmldata.toString(), mimetype, encoding, “”);
    “fake://host/path” is a fake url but you could also use your homepage or something.

    so something like :

    public void onCreate(Bundle savedInstanceState) {
    
    
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        getWindow().setFeatureInt( Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
        mWebView = (WebView) findViewById(R.id.webview);
        mWebView.setWebViewClient(new TimeClient());
    
        mWebView.setInitialScale(1);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.getSettings().setDomStorageEnabled(true);
        //mWebView.loadData(html, "text/html", "utf-8");
    
        //final Activity MyActivity = this;
        mWebView.setWebChromeClient(new WebChromeClient() {
         public void onProgressChanged(WebView view, int progress)  
         {
          //Make the bar disappear after URL is loaded, and changes string to Loading...
          MyActivity.setTitle("Loading...");
          MyActivity.setProgress(progress * 100); //Make the bar disappear after URL is loaded
    
          // Return the app name after finish loading
             if(progress == 100)
                MyActivity.this.setTitle(R.string.app_name);
           }
         });
    }
    
    public void onStart() {
       main(); 
       mWebView.loadData("fake://host/path",html, "text/html", "utf-8");
    }
    
    public void onStop() {
       // some JSoup disconnect code
    }
    

    then the webView will load every time the app is launched.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Browser : IE6/IE7. I want to load a new document into my html modal
Hai, I am using Java GWT. In this i want to load one html
I load some HTML code into a div with the .load function af jQuery
I want to load the data into session so that when the next button
I want to load some images into my application from the file system. There's
I want to load some data from mysql into my cocoa application view before
I am building a blog type page, and I want to load items into
I have an HTML document, with the jquery code $(function(){ [...] $(#newNotice).click(function(){ $(#properties).load(testDiagramm.html #NoticeForm);
i load a form into a jquery ui dialog. i have a submit button
I am trying to load HTML via JQuery, using the .load function. This is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.