2015-01-01 52 views
-3

我想創建一個Android應用程序,HTML字符串的WebView

的APK有一個文本框和一個按鈕,也許。

在文本框中,用戶將輸入他們的HTML代碼/字符串。 並通過單擊該按鈕,它將顯示從文本框中鍵入的代碼的輸出。

回答

2

,你可以做這樣的

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, ""); 
} 

} 

在menifest

<uses-permission android:name="android.permission.INTERNET"></uses-permission> 
添加此
0

呼叫這一行:

​​