【问题标题】:Android WebView Screen Goes black during load the next or same pageAndroid WebView 屏幕在加载下一页或同一页面时变黑
【发布时间】:2011-12-13 13:44:53
【问题描述】:

我们使用 webview 为三星 Galaxy 选项卡制作了一个 Android 应用程序,但是当我们点击同一页面或中间的不同页面时,在该屏幕显示该页面后会出现 4-5 秒的黑屏。 所以请告诉我我们为此做了什么,我不想要那个黑屏。 请在下面找到相同的代码。

CallKiosk.java

package one97.kiosk;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class CallKiosk extends Activity {
    public final String url = "http://10.0.8.178:8088/Kiosk/";
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WebView webview = new WebView(this);
        webview.getSettings().setJavaScriptEnabled(true); 
        webview.setWebViewClient(new WebViewClient());
        setContentView(webview); 
        webview.loadUrl(url); 
    }
    private class MyWebViewClient extends WebViewClient {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return false;
        }
    }
}

Main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    >
<WebView
    android:id="@+id/webview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    />

<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
</LinearLayout>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="one97.kiosk"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-sdk android:minSdkVersion="8" />

    <application android:icon="@drawable/logo" android:label="@string/app_name">
        <activity android:name=".CallKiosk"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>

【问题讨论】:

  • 我想在这个黑屏期间页面正在加载。只需显示进度对话框并等待页面加载:)
  • 如果有用的话试试这个,webview.setBackgroundColor("#FFFFFF");

标签: android android-layout android-emulator android-manifest


【解决方案1】:

如果有用,试试这个 webview.setBackgroundColor("#FFFFFF")

【讨论】:

    猜你喜欢
    • 2019-09-01
    • 1970-01-01
    • 2012-08-14
    • 1970-01-01
    • 2014-10-04
    • 2013-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多