Tuesday, 6 March 2018

Webview in android

WebView is a view that display web pages inside your application. You can also specify HTML string and can show it inside your application using WebView. WebView makes turns your application to a web application.
 First Add Permissions in Android : -
  <uses-permission android:name="android.permission.INTERNET" />  
JavaFile 
MainActivity.java: -  
package safal.bhatia.webview;
 import android.content.Intent;
 import android.net.Uri;
 import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
 import android.view.View;
import android.webkit.WebView;
 import android.widget.TextView;  
public class MainActivity extends AppCompatActivity
{
WebView web_view;
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);  
web_view = (WebView) findViewById(R.id.web_view); web_view.loadUrl("http://www.javatpoint.info"); web_view.setHorizontalScrollBarEnabled(false); //When we use java Script web_view.getSettings().setJavaScriptEnabled(true);
}
 }
 Xml File activity_main.xml: -
  <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
android:gravity="center"
android:layout_height="match_parent"
 tools:context="safal.bhatia.webview.MainActivity">
 <WebView android:layout_width="match_parent"
 android:id="@+id/web_view"
 android:layout_height="match_parent"/>
</LinearLayout>

9 comments:

  1. When I faced such as this one of yours, I wasn't feeling mazed at some level or something. Actually, I studied the Java programming for 2 solid years, so I know for sure that this thing is pretty common among a great variety of users. Back then, I was using many sources and even those "teach yourself coding everything in 2 minutes" books to obtaiт as much information as I can. But one resource of them I keep using nowadays as well. In general, these are the java tutorials explainjava.com/category/java/java-core/ but written in quite easy to understand language, so even somebody with zero experience in coding at all could get it. And it comes in use to me as a handbook to find the answers for all the common issues I'm forgetting myself frequently. But anyway, I was pretty surprised about how easily this one can be solved here

    ReplyDelete
  2. Your blogs are easily accessible and quite enlightening so keep doing the amazing work guys. vpn

    ReplyDelete
  3. I think this is definitely an amazing project here. So much good will be coming from this project. The ideas and the work behind this will pay off so much. die besten vpn

    ReplyDelete
  4. I'm constantly searching on the internet for posts that will help me. Too much is clearly to learn about this. I believe you created good quality items in Functions also. Keep working, congrats! vpnveteran

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Few people know this site, rorty popular online casinos and I know it will not deceive you for sure. Withdraw money whenever you want, play different gambling and slots Cool site and beautiful design.

    ReplyDelete
  7. Imagine yesterday went to some online casino copacetic gamble casino and decided to ponastalgirovat. so many pleasant memories when you again see this slot machine mmm cool

    ReplyDelete