AIDE Tutorial - 20.1 WebView with Progress Bar with JavaScript enabled
Xml
<FrameLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:id="@+id/fl">
<WebView
android:id="@+id/web"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ProgressBar
android:id="@+id/pb"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center"/>
</FrameLayout>
Manifest
<uses-permission android:name="android.permission.INTERNET"/>Java
package com.kc.webView1;import android.app.*;
import android.os.*;
import android.webkit.*;
import android.widget.*;
public class MainActivity extends Activity
{
private WebView web;
private ProgressBar pb;
private FrameLayout fl;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
web=(WebView)findViewById(R.id.web)
fl=(FrameLayout)findViewById(R.id.fl);
pb=(ProgressBar)findViewById(R.id.pb);
WebSettings WebSettings=web.getSettings();
WebSettings.setJavaScriptEnabled(true);
web.loadUrl("http://shyamkumarkc.blogspot.com");
web.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView View, String url){
l.removeView(pb);
}
});
}
}
Watch the video
You have wrap the source codes to downloadable file.
ReplyDelete