我无法看到我使用下面的新代码打开此网页视图。我让它使用注释掉的代码。我需要获取新代码来加载Web视图。我正在使用此示例代码。我怎样才能解决它没有打开页面的问题? 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;
答案 0 :(得分:1)
也许是因为你正在初始化同一个webview两次,而在第二次,你没有在它上面调用loadUrl()方法。
尝试在第二次初始化后设置url。问题是您要将内容视图设置为webview,但webview没有要加载的URL。