闪屏,而在Android应用程序一个的WebView加载一个url而在、应用程序、加载、闪屏

2023-09-12 01:07:28 作者:秋男

我有一个应用程序,有2个活动,第一个推出第二加载URL到一个web视图。

I've got an app, that has 2 activity, the first one launch the second to load a url into a webview.

它的工作原理,但在该URL加载,web视图显示为空......然后我想打一个闪屏或这样的事情,以显示它,而该URL加载,我这样做,在一个新的活动,但我不知道我能做些什么时,URL被加载,关闭第三个活动......请任何人可以帮助我吗?

It works, but while the url is loading , the webview appear empty... then i want to make a splash screen or something like this, to show it while the url is loading, I did that in a new activity, but i don't know what can i do to close the third activity when the url is loaded... Please can anybody help me?

这是我的code ...谢谢!

This is my code...Thank you!

公共类遮阳板延伸活动{

public class Visor extends Activity {

WebView mWebView;
int Result;

@Override
public void onCreate (Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.visor);
    Bundle extras=getIntent().getExtras();
    String s= extras.getString("url");

    mWebView = (WebView) findViewById(R.id.webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setPluginsEnabled(true);
    mWebView.getSettings().setAllowFileAccess(true);

    mWebView.loadUrl(s);
    mWebView.setWebViewClient(new VisorClient());
    mWebView.getSettings().setBuiltInZoomControls(true);

    }

private class VisorClient extends WebViewClient {

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            lanzarIntro();
        }
        @Override
        public void onPageFinished(WebView view, String url) {
            mWebView.loadUrl(url);
        }
 }

public void lanzarIntro(){
    Intent i=new Intent (this, Intro.class);

    startActivity(i);


}

}

推荐答案

我这样做,通过初步显示出了ImageView的再一次的WebView加载,交换​​这样的企业的知名度。

I do it by initially showing an ImageView and then once the WebView has loaded, swapping their visibility like this

        WebView wv = (WebView) findViewById(R.id.webView1);
        wv.getSettings().setJavaScriptEnabled(true);
        wv.setWebViewClient(new WebViewClient() {

            ...

            @Override
            public void onPageFinished(WebView view, String url) {
                //hide loading image
                findViewById(R.id.imageLoading1).setVisibility(View.GONE);
                //show webview
                findViewById(R.id.webView1).setVisibility(View.VISIBLE);
            }


        });     
        wv.loadUrl("http://yoururlhere.com");

和我的XML布局看起来像这样

And my xml layout looks like this

    <ImageView android:id="@+id/imageLoading1"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:visibility="visible"
        android:src="@drawable/vert_loading"
        />
    <WebView android:id="@+id/webView1"
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:visibility="gone"
        />