Advertisement
kitlolz012

Tutorials java and xml code

Nov 19th, 2023
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.95 KB | Source Code | 0 0
  1. Tutorial Java Code :
  2.  
  3. package com.example.gypsy;
  4.  
  5. import androidx.appcompat.app.AppCompatActivity;
  6. import android.os.Bundle;
  7. import android.webkit.WebChromeClient;
  8. import android.webkit.WebView;
  9.  
  10. public class Tutorials extends AppCompatActivity {
  11.  
  12.     @Override
  13.     protected void onCreate(Bundle savedInstanceState) {
  14.         super.onCreate(savedInstanceState);
  15.         setContentView(R.layout.activity_tutorials);
  16.  
  17.         WebView webView1 = findViewById(R.id.webView1);
  18.         loadYouTubeVideo(webView1, "https://www.youtube.com/embed/fEPalyEJ9gk?si=A71htOWYpm0mk0g9");
  19.  
  20.         WebView webView2 = findViewById(R.id.webView2);
  21.         loadYouTubeVideo(webView2, "https://www.youtube.com/embed/V2KCAfHjySQ?si=NVvmLaslMPR7Io7o");
  22.  
  23.         WebView webView3 = findViewById(R.id.webView3);
  24.         loadYouTubeVideo(webView3, "https://www.youtube.com/embed/L482ZAno-fY?si=MoeQoVu7YVmxK_Ha");
  25.  
  26.         WebView webView4 = findViewById(R.id.webView4);
  27.         loadYouTubeVideo(webView4, "https://www.youtube.com/embed/_ttcR7VDouE?si=As-s6H47gW7oPssU");
  28.  
  29.         WebView webView5 = findViewById(R.id.webView5);
  30.         loadYouTubeVideo(webView5, "https://www.youtube.com/embed/hb_iMGC3Wyo?si=aVfXZTMPeN4k_iKj");
  31.     }
  32.  
  33.     private void loadYouTubeVideo(WebView webView, String videoUrl) {
  34.         String iframe = "<iframe width=\"100%\" height=\"100%\" src=\"" +
  35.                 videoUrl +
  36.                 "\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen></iframe>";
  37.         webView.loadData(iframe, "text/html", "utf-8");
  38.         webView.getSettings().setJavaScriptEnabled(true);
  39.         webView.setWebChromeClient(new WebChromeClient());
  40.     }
  41. }
  42.  
  43.  
  44. XML Code  :
  45.  
  46. <?xml version="1.0" encoding="utf-8"?>
  47. <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
  48.     xmlns:app="http://schemas.android.com/apk/res-auto"
  49.     xmlns:tools="http://schemas.android.com/tools"
  50.     android:layout_width="match_parent"
  51.     android:layout_height="match_parent">
  52.  
  53.     <LinearLayout
  54.         android:layout_width="match_parent"
  55.         android:layout_height="match_parent"
  56.         android:orientation="vertical"
  57.         android:fillViewport="true">
  58.  
  59.  
  60.  
  61.         <TextView
  62.             android:layout_width="match_parent"
  63.             android:layout_height="match_parent"
  64.             android:text="How To Train Your Dragon" />
  65.  
  66.         <WebView
  67.             android:layout_width="match_parent"
  68.             android:layout_height="250sp"
  69.             android:id="@+id/webView1" />
  70.  
  71.         <TextView
  72.             android:layout_width="match_parent"
  73.             android:layout_height="wrap_content"
  74.             android:text="How To Train Your Dragon" />
  75.  
  76.         <WebView
  77.             android:layout_width="match_parent"
  78.             android:layout_height="250sp"
  79.             android:id="@+id/webView2" />
  80.  
  81.         <TextView
  82.             android:layout_width="match_parent"
  83.             android:layout_height="wrap_content"
  84.             android:text="How To Train Your Dragon" />
  85.  
  86.         <WebView
  87.             android:layout_width="match_parent"
  88.             android:layout_height="250sp"
  89.             android:id="@+id/webView3" />
  90.  
  91.         <TextView
  92.             android:layout_width="match_parent"
  93.             android:layout_height="wrap_content"
  94.             android:text="How To Train Your Dragon" />
  95.  
  96.         <WebView
  97.             android:id="@+id/webView4"
  98.             android:layout_width="match_parent"
  99.             android:layout_height="250sp" />
  100.  
  101.         <TextView
  102.             android:layout_width="match_parent"
  103.             android:layout_height="wrap_content"
  104.             android:text="How To Train Your Dragon" />
  105.  
  106.         <WebView
  107.             android:id="@+id/webView5"
  108.             android:layout_width="match_parent"
  109.             android:layout_height="250sp" />
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.     </LinearLayout>
  117. </ScrollView>
  118.  
  119.  
  120.  
  121.  
  122.  
Tags: Code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement