Java
package com.kc.webview3;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.webkit.*;
public class MainActivity extends Activity
{
private FrameLayout fl;
private ProgressBar pb;
private WebView web;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
web=(WebView) findViewById(R.id.web);
pb=(ProgressBar)findViewById(R.id.pb);
fl=(FrameLayout)findViewById(R.id.fl);
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){
fl.removeView(pb);
}
});
}
@Override
public void onBackPressed()
{
if(web.canGoBack()){
web.goBack();
}else{
// TODO: Implement this method
super.onBackPressed();
}
}
}
Xml
<FrameLayout xmlns: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_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</FrameLayout>
Manifest
Add permission
<uses-permission android:name="android.permission.INTERNET"/>
android:id="@+id/web"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ProgressBar
android:id="@+id/pb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</FrameLayout>
Manifest
Add permission
<uses-permission android:name="android.permission.INTERNET"/>
webview not work this coding
ReplyDeletewhat is price if you make me webview with admobs ad baner ad and reward ad i want to make web browser you can help me
ReplyDelete