0

我可以在我的WebView. 但是,如果我执行某些操作(例如单击事件),则会出现以下错误LogCat

Unable to get value of the property 't': object is null or undefinedundefined

但如果我从模拟器的浏览器执行一些事件,它工作正常。

这是基于帖子的代码:

public class MainActivity extends Activity {

WebView mWebview = null;
String URL = "********";  // Masked intentionally.

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    //setContentView(R.layout.activity_main); //Not required as per comment given by Raghunandan.

    mWebview  = new WebView(this);

    mWebview.getSettings().setJavaScriptEnabled(true); // enable javascript

    final Activity activity = this;

    mWebview.setWebChromeClient(new WebChromeClient());

    mWebview.setWebViewClient(new WebViewClient() {
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            Toast.makeText(activity, description, Toast.LENGTH_SHORT).show();
        }
    });

    mWebview .loadUrl(URL);
    setContentView(mWebview );

    }
}

注意:网页是使用AngularJS.

我在以下位置添加了以下属性Manifiest.xml

<uses-permission android:name="android.permission.INTERNET" /> 
4

0 回答 0