Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
426 views
in Technique[技术] by (71.8m points)

java - How to create/update/load a HTML file at runtime

I need to create and open an HTML file at runtime.

    <html>
      <body>
        <form name="Home" method="POST" action='' >
          <input id='Title' type='hidden' value="Mr" name='Title'/>
          <input id='Name' type='hidden' value="bala" name='Name'/>
           .
           .
           .
         </form>
         <script language='javascript'>
            //java script
         </script>
      </body>
    </html>

In above format, i need to update value field at runtime. After updating I want to open this html file within my android application.

Update: I know we can crate HTML file like below..

public static String createHTML(Study study) {
    String format =
            "<html>" +
            "<body>" +
            "<form name="Home" method="POST" action='' >" +
            "<input id='Title' type='hidden' value='%d' name='Title'/>" +
            .
            .
            .
            .
            "   </body>" +
            "</html>";
    return String.format(format, study.title, study.name...);
}

but i wank to know is there any other way to create HTML file like creating XML file using XmlSerializer Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you want to run html file runtime then try using this code.

 webview_data.loadDataWithBaseURL("file:///android_asset/", htmlString,"text/html", "UTF-8",null);

And make sure if you want to use any css or javascript file then put it into android assest folder..


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...