Posts

[ KOTLIN ] WEBVIEW IN FRAGMENT WITH NAVIGATION DRAWER






STEP 1:  CREATE A NEW PROJECT WITH A NAVIGATION DRAWER AND BLANK FRAGMENT ( CLICK HERE FOR COMPLETE GUIDE)



STEP 2 : COPY AND PASTE THE FOLLOWING CODE IN XML AND KOTLIN FRAGMENT ACTIVITY.

XML CODE : 

<WebView
    android:id="@+id/webView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerHorizontal="true"
    tools:layout_editor_absoluteX="16dp"
    tools:layout_editor_absoluteY="0dp" />



KOTLIN CODE :

val  mWebView = view.findViewById(R.id.webView1) as WebView
mWebView.loadUrl("https://onlinepaisa555.blogspot.in/")

val webSettings = mWebView.getSettings()
webSettings.setJavaScriptEnabled(true)

// Force links and redirects to open in the WebView instead of in a browser
mWebView.setWebViewClient(WebViewClient())



MANIFEST CODE :

  <uses-permission android:name="android.permission.INTERNET" />

Done. Run App

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.