Issue
I am creating an Android project in which I have created a Webview. When the page loads, the progress bar runs. When the page is 100% loaded then the progress bar becomes hidden
But i don't know how to hide it
ProgressBar Code:
@Override
public void onProgressChanged(WebView view,int newProgress)
{
super.onProgressChanged(view, newProgress);
superProgressBar.setProgress(newProgress);
}
All Code:
package com.djaman.musicwala;
import android.app.*;
import android.os.*;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.webkit.WebSettings;
import android.widget.ProgressBar;
import android.widget.ImageView;
import android.webkit.WebChromeClient;
import android.graphics.Bitmap;
import android.support.v7.app.ActionBar;
public class MainActivity extends Activity
{
ProgressBar superProgressBar;
ImageView superImageView;
WebView superWebView;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
superWebView = (WebView) findViewById(R.id.webview);
superProgressBar = (ProgressBar) findViewById(R.id.myProcessBar);
superImageView = (ImageView) findViewById(R.id.myImageView);
superProgressBar.setMax(100);
superWebView.loadUrl("http://musicwala.cf");
superWebView.getSettings().setJavaScriptEnabled(true);
superWebView.setWebViewClient(new WebViewClient());
superWebView.setWebChromeClient(new WebChromeClient(){
@Override
public void onProgressChanged(WebView view,int newProgress)
{
super.onProgressChanged(view, newProgress);
superProgressBar.setProgress(newProgress);
}
@Override
public void onReceivedTitle(WebView view,String title)
{
super.onReceivedTitle(view, title);
}
@Override
public void onReceivedIcon(WebView view,Bitmap icon)
{
super.onReceivedIcon(view, icon);
superImageView.setImageBitmap(icon);
}
});
}
private WebView findViewById()
{
// TODO: Implement this method
return null;
}
@Override
public void onBackPressed()
{
// TODO: Implement this method
if(superWebView.canGoBack())
{
superWebView.goBack();
}else{
super.onBackPressed();
}
}
}
Solution
you can try this in your "onProgressChanged()".
if (newProgress == 100) {
superProgressBar.setVisibility(View.GONE);
} else {
superProgressBar.setVisibility(View.VISIBLE);
superProgressBar.setProgress(newProgress);
}
Answered By - igarasi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.