简体   繁体   English

WebView在4.2.2中不会显示静态HTML,但在2.3.3中可以使用

[英]WebView won't display static HTML in 4.2.2, but works in 2.3.3

I can't get a WebView to display static HTML. 我无法通过WebView显示静态HTML。 It works in Android 2.3.3 but not in 4.2.2. 它适用于Android 2.3.3,但不适用于4.2.2。 No similar questions appear relevant, as I'm not using Javascript, HTTPS, and I tried clicking on the view. 没有类似的问题相关,因为我没有使用Javascript,HTTPS,并且尝试单击视图。 I tried the documentation http://developer.android.com/reference/android/webkit/WebView.html 我尝试了文档http://developer.android.com/reference/android/webkit/WebView.html

TmpActivity.java TmpActivity.java

public class TmpActivity extends Activity {

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tmp);
        WebView webView = (WebView) findViewById(R.id.webView1);
        webView.loadData("<html><body>You scored <b>192</b> points.</body></html>","texl/html","UTF-8");
    }

activity_tmp.xml activity_tmp.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".TmpActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

    <WebView
        android:id="@+id/webView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/textView1"
        android:layout_marginTop="20dp" />

</RelativeLayout>

Emulator running 2.3.3 运行2.3.3的模拟器

Imgur

Emulator running 4.2.2 运行4.2.2的模拟器

Imgur

There are no errors in the logs. 日志中没有错误。 The only error is 唯一的错误是

05-25 00:56:20.563: E/Trace(4140): error opening trace file: No such file or directory (2) 05-25 00:56:20.563:E / Trace(4140):打开跟踪文件时出错:没有这样的文件或目录(2)

Looks like a typo 看起来像错字

texl/html -> text/html texl / html->文本/ html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android 2.3.3中的NotificationCompat破解,但在Android 4.2.2中运行良好 - NotificationCompat crack in Android 2.3.3 but works well in Android 4.2.2 Android中的Webview只能在4.2+版本中使用,而不能在2.3.3中使用 - Webview in Android which works in 4.2+ and not in 2.3.3 Lollipop上的WebView不起作用,但它适用于Kitkat - WebView on Lollipop won't work but it works on Kitkat ListView读取文件,但WebView不会显示它 - ListView reads the file, but WebView won't display it 为什么在使用WebView的Fragment中不会显示软键盘 - Why softkeyboard won't display in Fragment with WebView 网页流量将不显示发布后的网址 - Webview won't display url after publishing WebView无法在Android 4.2.2上弹出softinput - webview can't popup softinput on android 4.2.2 2.3.3(级别10)上的Android模拟器在禁用hw键盘时不会旋转显示 - Android emulator on 2.3.3 (level 10) won't rotate display with hw keyboard disabled 我的应用程序在Android版本2.3.3上运行良好,但在android 4.2.2上无法运行 - My application works fine on Android version 2.3.3 but does not work on android 4.2.2 网站无法在android webview中加载,但可以在android浏览器中正常运行 - Website won't load in android webview but works fine in android browsers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM