[英]Android webview loads content sometimes
I have a problem with the webview, as it sometimes loads the content and sometimes not. 我对webview有问题,因为它有时加载内容,有时不加载内容。
I have noticed that there is no problem with the 2.2 and 2.3.3 Android versions, only with the 4.0.4 Android versions. 我注意到2.2和2.3.3 Android版本没有问题,只有4.0.4 Android版本没有问题。
My code is: 我的代码是:
public class MywebviewActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.mywebview);
final Activity MywebviewActivity = this;
// Makes Progress bar Visible
getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
android.webkit.WebView wv =
(android.webkit.WebView)this.findViewById(R.id.myWebView);
wv.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
//Make the bar disappear after URL is loaded, and changes string to Loading...
MywebviewActivity.setTitle("Loading...");
MywebviewActivity.setProgress(progress * 100); //Make the bar disappear after URL is loaded
// Return the app name after finish loading
if(progress == 100)
MywebviewActivity.setTitle(R.string.web_app_name);
}
});
wv.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
wv.getSettings().setJavaScriptEnabled(true);
wv.setHorizontalScrollBarEnabled(false);
wv.loadUrl("http://mypagename.com/android/server/app/ver10/page1.html");
}
public void onBackPressed() {
android.os.Process.killProcess(android.os.Process.myPid());
return;
}
Hardware acceleration carries out all drawing operations that are performed on a View's canvas using the GPU . 硬件加速执行使用GPU在View画布上执行的所有绘图操作。 Check whether the application is hardware accelerated:
检查应用程序是否通过硬件加速:
View.isHardwareAccelerated()
View.isHardwareAccelerated()
returns true if the View is attached to a hardware accelerated window. 如果View附加到硬件加速窗口,则返回true。 If it returns false , add
如果返回false,则添加
android:hardwareAccelerated ="true"
android:hardwareAccelerated =“ true”
for the <activity
对于
<activity
element in Manifest file . 清单文件中的元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.