Android code for reference and stop key for webview

Reference key for webview in android
stop key in android for webview

ourSite is variable assigned to webView

WebView ourSite = (WebView) findViewById(R.id.webView1);

Reference:-

Add following code inside reference key

ourSite.reload();

Stop key:-

Add following code inside stop key

ourSite.stopLoading();


Example:-

 Button refs_key = (Button) findViewById(R.id.button01);
 Button stop_key = (Button) findViewById(R.id.button01);

refs_key.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View arg0) {
WebView ourSite = (WebView) findViewById(R.id.webView1);
// TODO Auto-generated method stub
ourSite.reload();
                               

}
});

stop_key.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View arg0) {
WebView ourSite = (WebView) findViewById(R.id.webView1);
// TODO Auto-generated method stub
ourSite.stopLoading();
                         
}
});

Import header file
//for button
import android.widget.Button;
//for webview
import android.webkit.WebView;

Leave reply

Add your comments here

Back to Top