创建了一个Android应用程序,我在其中通过webview加载了一个网站。我已经使我的启动画面加载了5秒并且在其间放置了进度条,以便调整网站加载所花费的时间。
现在我需要显示启动画面,直到页面加载完毕并决定删除进度条页面。我正在使用以下代码。
public class Splashscreen extends Activity {
// Set Duration of the Splash Screen
long Delay = 5000;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Remove the Title Bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
// Get the view from splash_activity.xml
setContentView(R.layout.splash);
// Create a Timer
Timer RunSplash = new Timer();
// Task to do when the timer ends
TimerTask ShowSplash = new TimerTask() {
@Override
public void run() {
// Close SplashScreenActivity.class
finish();
// Start MainActivity.class
Intent myIntent = new Intent(Splashscreen.this,
MainActivity.class);
startActivity(myIntent);
}
};
// Start the timer
RunSplash.schedule(ShowSplash, Delay);
}
}
我应该在哪里进行更改?
答案 0 :(得分:1)
当您在import SOAPpy
wsdlFile = 'https://10.10.10.10/services/fwif?wsdl'
proxy = SOAPpy.WSDL.Proxy(wsdlFile)
Traceback (most recent call last):
File "run.py", line 28, in <module>
proxy = SOAPpy.WSDL.Proxy(wsdlFile)
File "/home/dinn/miniconda/envs/soaptest/lib/python2.7/site-packages/SOAPpy/WSDL.py", line 83, in __init__
self.wsdl = reader.loadFromString(str(wsdlsource))
File "/home/dinn/miniconda/envs/soaptest/lib/python2.7/site-packages/wstools/WSDLTools.py", line 49, in loadFromString
return self.loadFromStream(StringIO(data))
File "/home/dinn/miniconda/envs/soaptest/lib/python2.7/site-packages/wstools/WSDLTools.py", line 28, in loadFromStream
document = DOM.loadDocument(stream)
File "/home/dinn/miniconda/envs/soaptest/lib/python2.7/site-packages/wstools/Utility.py", line 645, in loadDocument
return xml.dom.minidom.parse(data)
File "/home/dinn/miniconda/envs/soaptest/lib/python2.7/xml/dom/minidom.py", line 1918, in parse
return expatbuilder.parse(file)
File "/home/dinn/miniconda/envs/soaptest/lib/python2.7/xml/dom/expatbuilder.py", line 928, in parse
result = builder.parseFile(file)
File "/home/dinn/miniconda/envs/soaptest/lib/python2.7/xml/dom/expatbuilder.py", line 207, in parseFile
parser.Parse(buffer, 0)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 6
时,无法从其他WebView
加载Activity
。您需要加载Splashscreen
并将启动画面覆盖在MainActivity
上。
答案 1 :(得分:1)
您必须在同一活动中制作启动画面和Web视图。要知道页面何时完成加载,您可以将此方法与您的webview一起使用。
webview.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
}
});
在onPageFinished()方法中,您可以关闭进度条
答案 2 :(得分:0)
请查看此链接,了解如何在 webview 加载页面之前显示进度条
https://medium.com/android-news/loading-splash-screen-for-webview-in-android-studio-ef68ec05720a。