2016-09-19 6 views
0

私はWebView内のYouTubeページをロードしようとしています:それは私にOpen Withメニューを開き、任意のアイデアWebViewの負荷ユーチューブのページ

webview = (WebView) findViewById(R.id.webview); 
webview.loadUrl(new String("http://youtube.com")); 

しかし、私はそれを行っ代わりに、すべての時間が私にWebView内のページのコンテンツを表示私はどのようにYouTubeのページを表示することができますか?

+0

..役立ちます可能性があり、あなたのアプリケーションINTERNET権限を与えられたことがありますか? – x13

+0

手段 "選択"で開くか? – kgandroid

答えて

0
 mWebView = (WebView) findViewById(R.id.webView); 
     WebSettings settings = mWebView.getSettings(); 
     settings.setJavaScriptEnabled(true); 
     settings.setAllowFileAccess(true); 
     if (Build.VERSION.SDK_INT > 7) { 
      settings.setPluginState(PluginState.ON); 
     } else { 
      settings.setPluginsEnabled(true); 
     } 

     String html = ""; 
     html += "<html><body>"; 
     html += "<iframe width=\"560\" height=\"315\" src=\"http://www.youtube.com/embed/MU9Srs04sFU?rel=0\" frameborder=\"0\" allowfullscreen></iframe>"; 
     html += "</body></html>"; 

mWebView.loadData(html, "text/html", null); 

このロジック(ヒント)あなたは

関連する問題