i have developed an application that have one web view and one progress bar so i want to add functionality like show progress in progress bar of loading web page so how it implement i have code that i put here.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
web = (WebView) findViewById(R.id.web);
progressBar = (ProgressBar) findViewById(R.id.progrss);
web.setWebViewClient(new myWebClient());
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl("http://www.technotalkative.com");
}
public class myWebClient extends WebViewClient {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// TODO Auto-generated method stub
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
// TODO Auto-generated method stub
super.onPageFinished(view, url);
progressBar.setVisibility(View.GONE);
}
}
}
layout file..
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ProgressBar
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_gravity="center"
android:id="@+id/progrss"
style="?android:attr/progressBarStyleHorizontal"
android:progressDrawable="@drawable/blue_progressbar"
/>
<WebView
android:id="@+id/web"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1">
</WebView>
</LinearLayout>