Android WebView example Tutorial
WebView allows you to open an own windows for viewing URL or custom html markup page.
Perform a simple unpacking of tahasivaci.com. First of all in Activity we drag and drop a webView from the palette.
Layout
- File:res/layout/activity_main
2 3 4 5 6 7 8 9 10 11 |
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <WebView android:id="@+id/webView" android:layout_width="match_parent" android:layout_height="match_parent"> </WebView> </FrameLayout> |
MainActivity
- You can enter any site you want to see in url
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
public class MainActivity extends AppCompatActivity { WebView web; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); web=(WebView)findViewById(R.id.webView); web.getSettings().setJavaScriptEnabled(true); web.setWebViewClient(new WebViewClient()); web.loadUrl("http://www.tahasivaci.com"); } } |
AndroidManifest
- Do not forget to add the INTERNET permission to the manifest file
2 |
<uses-permission android:name="android.permission.INTERNET" /> |
- I show you the location where you will add more details
Run Code
if you have question do not forget to write from the chat button next to it or from the comment
Recent Comments