填写表单时,Android WebView变黑

时间:2012-02-23 04:02:12

标签: android forms webview

使用android webview填写我的应用加载的表单时遇到此问题:

https://lh6.googleusercontent.com/-lik5GC5CcIU/T0W5n9dJeTI/AAAAAAAABrM/JIlqB5_Tq9Q/s1130/webview-blackout-problem.jpg

抱歉,我无法直接发布图片,因为我是新来的,所以StackOverflow不允许我这样做。

正如您所看到的,当我尝试填写文本字段时,屏幕的某些部分变为黑色。谢谢你的帮助!

我使用的代码:

package com.example.WebViewer;

import android.app.Activity;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;


public class WebViewerActivity extends Activity {
     /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          //setContentView(R.layout.main);

          // Let's display the progress in the activity title bar, like the
          // browser app does.
          getWindow().requestFeature(Window.FEATURE_PROGRESS);

          WebView webview = new WebView(this);
          setContentView(webview);

          webview.getSettings().setJavaScriptEnabled(true);

          final Activity activity = this;
          webview.setWebChromeClient(new WebChromeClient() {
          public void onProgressChanged(WebView view, int progress) {
               // Activities and WebViews measure progress with different scales.
               // The progress meter will automatically disappear when we reach 100%
               activity.setProgress(progress * 1000);
          }
        });

        webview.setWebViewClient(new WebViewClient() {      
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                      //Users will be notified in case there's an error (i.e. no internet connection)
                      Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
            }
        });
        //This will load the webpage that we want to see

        String url = "file:///" 
                        + Environment.getExternalStorageDirectory() 
                        + "/SomeFiles/Downloads/SalesOrderForms/4_2.html";

        webview.loadUrl(url);

        Log.e("URL", url);

     }
}

我也在该页面上使用jQuery。我试图删除它,但我得到了相同的结果。

我尝试在HTML查看器中查看它,但屏幕的某些部分变为白色而不是黑色。

我尝试在设备浏览器中查看它,似乎没问题。

我正在使用10.1英寸的三星Galaxy标签。用android 3.0 os

1 个答案:

答案 0 :(得分:0)

你试过了吗?

webview.getSettings().setJavaScriptEnabled(true); // TRUE because you are using JS as you said