Android 在WebView中按回时显示白色屏幕

Android 在WebView中按回时显示白色屏幕,android,webview,Android,Webview,我能够浏览“index.html”页面。当我在页面的一个链接中时,尝试返回主页,即“index.html”。它会显示一个白色屏幕 我一直在寻找解决办法,但徒劳无功 package com.veereshc.veer.vturesults; import android.content.Context; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.view.Ke

我能够浏览“index.html”页面。当我在页面的一个链接中时,尝试返回主页,即“index.html”。它会显示一个白色屏幕

我一直在寻找解决办法,但徒劳无功

package com.veereshc.veer.vturesults;

import android.content.Context;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

import java.io.IOException;
import java.io.InputStream;


public class MainActivity extends ActionBarActivity {

WebView webView;
Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    webView = new WebView(this);

    context = this;
    WebViewClient client = new WebViewClient();
    webView.setWebViewClient(client);
    setContentView(webView);



        try {
           InputStream stream = this.getAssets().open("index.html");
            int streamSize = stream.available();
            byte[] buffer = new byte[streamSize];
            stream.read(buffer);
            stream.close();
            String html = new String(buffer);
            webView.loadDataWithBaseURL("file:///android_asset/", html, "text/html", "UTF-8", null);
    }
    catch (IOException e){
        e.printStackTrace();
    }



}



@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}




@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

}

根据您当前的代码,我可以说您不需要设置客户端。删除这两行,您的webview将按预期工作,即没有空白屏幕

WebViewClient client = new WebViewClient();
webView.setWebViewClient(client)

我在你的代码中看不到任何反向处理逻辑,它只是一个带有链接的html页面……但是当我在另一个链接中按back时,屏幕会变白