[英]Getting a webview to load with webchromeclient
I cant see me get this web view to open up with the new code below. 我看不到我可以通过以下新代码打开此网络视图。 I had it working with the commented out code. 我有它与注释掉的代码一起工作。 I need to get the new code to load the web view. 我需要获取新代码以加载Web视图。 Im using this sample code. 我正在使用此示例代码。 How can i fix the issues of it not opening up the page? 我该如何解决无法打开页面的问题? The Sample code 样例代码
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
if(requestCode==FILECHOOSER_RESULTCODE)
{
if (null == mUploadMessage) return;
Uri result = intent == null || resultCode != RESULT_OK ? null
: intent.getData();
mUploadMessage.onReceiveValue(result);
mUploadMessage = null;
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.register:
//mWebView2 = (WebView) findViewById(R.id.webview);
// mWebView2.getSettings().setJavaScriptEnabled(true);
// mWebView2.loadUrl("http://www.Mysite.com/AndroidAddMember.aspx");
//mWebView2.setWebViewClient(new HelloWebViewClient());
wv = new WebView(this);
wv.setWebViewClient(new WebViewClient());
wv.getSettings().setJavaScriptEnabled(true);
wv.loadUrl("http://www.Mysite.com/AndroidAddMember.aspx");
wv.setWebViewClient(new WebViewClient());
wv.setWebChromeClient(new WebChromeClient()
{
//The undocumented magic method override
//Eclipse will swear at you if you try to put @Override here
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
mUploadMessage = uploadMsg;
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
BangMeorNot.this.startActivityForResult(Intent.createChooser(i,"File Chooser"), FILECHOOSER_RESULTCODE);
}
});
setContentView(wv);
return true;
Maybe because you are initializing the same webview twice and during the second time, you are not calling loadUrl() method on it. 可能是因为您要两次初始化同一Webview,并且在第二次初始化时,您没有在其上调用loadUrl()方法。
Try setting the url after the second initialization also. 也尝试在第二次初始化后设置网址。 The problem is that you are setting the content view to the webview, but the webview has no url to load. 问题是您正在将内容视图设置为Web视图,但是Web视图没有要加载的URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.