rogressvideo == null) {
LayoutInflater inflater = LayoutInflater.from(MainActivity.this);
xprogressvideo = inflater.inflate(R.layout.video_loading_progress, null);
}
return xprogressvideo;
}
//网页标题
@Override
public void onReceivedTitle(WebView view, String title) {
(MainActivity.this).setTitle(title);
}
// @Override
// //当WebView进度改变时更新窗口进度
// public void onProgressChanged(WebView view, int newProgress) {
// (MainActivity.this).getWindow().setFeatureInt(Window.FEATURE_PROGRESS, newProgress*100);
// }
}
/**
* 处理各种通知、请求等事件
* @author
*/
public class xWebViewClientent extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.i("webviewtest", "shouldOverrideUrlLoading: "+url);
return false;
}
}
/**
* 当横竖屏切换时会调用该方法
* @author
*/
@Override
public void onConfigurationChanged(Configuration newConfig) {
Log.i("testwebview", "=====<<< onConfigurationChanged >>>=====");
super.onConfigurationChanged(newConfig);
if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE){
Log.i("webview", " 现在是横屏1");
islandport = false;
}else if(newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
Log.i("webview", " 现在是竖屏1");
islandport = true;
}
}
}
最后说下AndroidManifest.xml设置; 访问网络权限加上这句 <uses-permission android:name="android.permission.INTERNET"/> 当切换横竖屏时为了不重新调用onCreate等方法,要加个这句: android:configChanges="orientation|keyboardHidden|screenSize"
完成
参考于:https://www.cnblogs.com/lee0oo0/p/4039654.html
|