我尝试了谷歌搜索的每个示例,但它不起作用。当我在 Sony Tablet S 中运行我的应用程序时,LogCat 中显示 NullPointerException,然后强制关闭。:(
非常感谢你。
public class Lesson_4 extends Fragment {
WebView myWebView;
WebChromeClient chromeClient;
WebViewClient wvClient;
/**
* (non-Javadoc)
*
* @see android.support.v4.app.Fragment#onCreateView(android.view.LayoutInflater,
* android.view.ViewGroup, android.os.Bundle)
*/
public View onCreateView(final LayoutInflater inflater,
final ViewGroup container, Bundle savedInstanceState) {
if (container == null) {
return null;
}
LinearLayout mLinearLayout = (LinearLayout) inflater.inflate(
R.layout.lessons4, container, false);
myWebView = (WebView) (getView().findViewById(R.id.webView));
myWebView.setWebChromeClient(new WebChromeClient());
myWebView.setWebViewClient(wvClient);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setPluginsEnabled(true);
myWebView.loadUrl("http://www.youtube.com/watch?v=iNcNOMiSQ5I");
return mLinearLayout;
}
}