你好,我需要在我的应用程序中添加后退按钮有人可以帮助我吗?
这是我的代码
公共类 Showing_now 扩展 SherlockFragment{
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View mainView = (View) inflater.inflate(R.layout.activity_showing_now, container, false);
WebView webView = (WebView) mainView.findViewById(R.id.webViewsn);
webView.setWebViewClient(new MyWebViewClient());
webView.getSettings().setPluginsEnabled(true);
webView.getSettings().setBuiltInZoomControls(false);
webView.getSettings().setSupportZoom(false);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setPluginState(PluginState.ON);
webView.loadUrl("http://www.mywebsite.com");
return mainView;
} 公共类 MyWebViewClient 扩展 WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("http://m.youtube.com")||url.startsWith("http://www.youtube.com")) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
}
return false;
}
}
}