【发布时间】:2015-01-01 12:59:48
【问题描述】:
我想创建一个安卓应用,
apk 可能有一个文本框和一个按钮。
用户将在文本框中输入他们的 HTML 代码/字符串。 通过单击按钮,它将显示他们从文本框中键入的代码的输出。
【问题讨论】:
我想创建一个安卓应用,
apk 可能有一个文本框和一个按钮。
用户将在文本框中输入他们的 HTML 代码/字符串。 通过单击按钮,它将显示他们从文本框中键入的代码的输出。
【问题讨论】:
你可以这样做
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
WebView wv = (WebView) findViewById(R.id.WebView01);
final String mimeType = "text/html";
final String encoding = "UTF-8";
String html = "<br /><br />Read the handouts please for tomorrow.<br /><br /><!--homework help homework" +
"help help with homework homework assignments elementary school high school middle school" +
"// --><font color='#60c000' size='4'><strong>Please!</strong></font>" +
"<img src='http://www.homeworknow.com/hwnow/upload/images/tn_star300.gif' />";
wv.loadDataWithBaseURL("", html, mimeType, encoding, "");
}
}
在清单中添加这个
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
【讨论】:
拨打此行:
wv.loadData(yourHtmlData, "text/html", "UTF-8");
【讨论】: