Pages

Tuesday, April 30, 2013

Splash Screen and Webiview

public class Splash extends Activity { 
     @Override 
     public void onCreate(Bundle icicle) { 
          super.onCreate(icicle); 
          setContentView(R.layout.splashscreen); 
 mProgressBar=(ProgressBar)findViewById(R.id.progressBar1);

        final WebView wvc = (WebView)findViewById(R.id.webview); 
        wvc.getSettings().setJavaScriptEnabled(true); 
        wvc.setWebViewClient(new WebViewClient() { 
          @Override 
          public void onPageFinished(WebView view, String url) 
          { 
              /* Call whatever, It's finished loading. */ 
                  wvc.setVisibility(View.VISIBLE); 
   mProgressBar.setVisibility(view.GONE);
                  } 
      }); 
        wvc.loadUrl("http://www.google.de"); 

     } 



// LAYOUT FILE // 
 Initially show an ImageView and then once the WebView has loaded, swapping their visibility like this
<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 



       <ImageView 
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent" 
                android:scaleType="center" 
                android:src="@drawable/splash" 
                android:visibility="visible" 
        /> 

        <WebView android:id="@+id/webview" 
            android:layout_height="fill_parent" 
            android:layout_width="fill_parent" 
            android:visibility="gone" 
         /> 

<ProgressBar
        android:id="@+id/progressBar1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:layout_gravity="center|bottom"/>

</FrameLayout> 

orr


public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView weeb = (WebView)findViewById(R.id.webView1);
WebSettings webSettings = weeb.getSettings();
webSettings.setJavaScriptEnabled(true);
weeb.setWebViewClient(new WebViewClient());
weeb.loadUrl(("http://www.facebook.com"));

}

No comments:

Post a Comment