Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid WebView won't work properly
    primarykey
    data
    text
    <p>I'm little bit struggle when i load the YouTube video url in a android webview. I load the embed code of that particular YouTube video link into the webview. I successfully loaded. Here my problem is, i must load more than 10 links, so i used scrollview (i used listview also) to show the loaded links. when i scroll the layout it placed over the header layout and also it's not loaded properly. Here i post my code with my output screenshot any one please help me to solve this problem. Thanks in advance.</p> <p><strong>main.xml</strong></p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;include android:id="@+id/header" layout="@layout/header_layout" /&gt; &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_below="@+id/header" android:orientation="vertical" android:scrollbars="none" &gt; &lt;RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="2dp" &gt; &lt;!-- &lt;ImageView --&gt; &lt;!-- android:id="@+id/inner_image" --&gt; &lt;!-- android:layout_width="fill_parent" --&gt; &lt;!-- android:layout_height="wrap_content" --&gt; &lt;!-- android:layout_below="@+id/inner_image" --&gt; &lt;!-- android:background="@drawable/lyrics_inner" /&gt; --&gt; &lt;WebView android:id="@+id/web" android:layout_width="fill_parent" android:layout_height="wrap_content" /&gt; &lt;WebView android:id="@+id/web1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/web" /&gt; &lt;WebView android:id="@+id/web2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/web1" /&gt; &lt;WebView android:id="@+id/web3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/web2" /&gt; &lt;WebView android:id="@+id/web4" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/web3" /&gt; &lt;/RelativeLayout&gt; &lt;/ScrollView&gt; &lt;/RelativeLayout&gt; </code></pre> <p><strong>header_layout.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/header_backButton" android:layout_width="fill_parent" android:layout_height="60dp" android:background="#333322" android:gravity="center_horizontal" android:text="HOME" android:textStyle="bold" android:textSize="30sp" android:textColor="#FFFFFF" /&gt; </code></pre> <p><strong>YoutubeActivity.java</strong></p> <pre><code>package com.devappandroid.youtube; import android.app.Activity; import android.os.Bundle; import android.view.Window; import android.webkit.WebSettings; import android.webkit.WebView; public class YoutubeActivity extends Activity { /** Called when the activity is first created. */ private String src_value = "http://www.youtube.com/v/9WFvopZMty4?version=3&amp;feature=player_embedded"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); WebView myWebView = (WebView) findViewById(R.id.web); WebView myWebView1 = (WebView) findViewById(R.id.web1); WebView myWebView2 = (WebView) findViewById(R.id.web2); WebView myWebView3 = (WebView) findViewById(R.id.web3); WebView myWebView4 = (WebView) findViewById(R.id.web4); myWebView.getSettings().setPluginState(WebSettings.PluginState.ON); myWebView1.getSettings().setJavaScriptEnabled(true); myWebView1.getSettings() .setJavaScriptCanOpenWindowsAutomatically(false); myWebView1.getSettings().setPluginsEnabled(true); myWebView1.getSettings().setSupportMultipleWindows(false); myWebView1.getSettings().setSupportZoom(false); myWebView1.setVerticalScrollBarEnabled(false); myWebView1.setHorizontalScrollBarEnabled(false); myWebView2.getSettings().setJavaScriptEnabled(true); myWebView2.getSettings() .setJavaScriptCanOpenWindowsAutomatically(false); myWebView2.getSettings().setPluginsEnabled(true); myWebView2.getSettings().setSupportMultipleWindows(false); myWebView2.getSettings().setSupportZoom(false); myWebView2.setVerticalScrollBarEnabled(false); myWebView2.setHorizontalScrollBarEnabled(false); myWebView3.getSettings().setJavaScriptEnabled(true); myWebView3.getSettings() .setJavaScriptCanOpenWindowsAutomatically(false); myWebView3.getSettings().setPluginsEnabled(true); myWebView3.getSettings().setSupportMultipleWindows(false); myWebView3.getSettings().setSupportZoom(false); myWebView3.setVerticalScrollBarEnabled(false); myWebView3.setHorizontalScrollBarEnabled(false); myWebView4.getSettings().setJavaScriptEnabled(true); myWebView4.getSettings() .setJavaScriptCanOpenWindowsAutomatically(false); myWebView4.getSettings().setPluginsEnabled(true); myWebView4.getSettings().setSupportMultipleWindows(false); myWebView4.getSettings().setSupportZoom(false); myWebView4.setVerticalScrollBarEnabled(false); myWebView4.setHorizontalScrollBarEnabled(false); String newPlay = "&lt;object style=\"height: 250px; width: 250px\"&gt;&lt;param name=\"movie\" value=" + src_value + "\"&gt;&lt;param name=\"allowFullScreen\" value=\"true\"&gt;&lt;param name=\"allowScriptAccess\" value=\"always\"&gt;&lt;embed src=" + src_value + " type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowScriptAccess=\"always\" width=\"360\" height=\"360\"&gt;&lt;/object &gt;"; myWebView.loadData(newPlay, "text/html", "utf-8"); myWebView1.loadData(newPlay, "text/html", "utf-8"); myWebView2.loadData(newPlay, "text/html", "utf-8"); myWebView3.loadData(newPlay, "text/html", "utf-8"); myWebView4.loadData(newPlay, "text/html", "utf-8"); } } </code></pre> <p>output screenshot: <img src="https://i.stack.imgur.com/cvLzY.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload