TabHost\WebView embedded youtube video float issue
I have a TabHost with 3 TabSpecs. One tab is using a WebView and when I load a url that has an embedded youtube video and then click on another tab, the youtube video floats above its containing tab and is visible on subsequent tabs. I need the video to NOT be visible when another tab is selected.
Screenshot
The application is built using this tutorial : "http://developer.android.com/resources/tutorials/views/hello-tabwidget.html"
I have modified the ArtistsActivity to use a WebView:
开发者_开发技巧import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class ArtistsActivity extends Activity{
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
WebView view = new WebView(this);
view.getSettings().setJavaScriptEnabled(true);
view.getSettings().setPluginsEnabled(true);
view.setWebViewClient(new MyWebViewClient());
view.loadUrl("http://www.jaydial.net/android/youtube.htm");
setContentView(view);
}
private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
}
Any suggestions on how to fix this?
Thanks
JayDial
Just load a blank string into the webview when you leave the current tab.
webview.loadData("", "text/html", "utf-8");
http://yue-gao.blogspot.com/2010/12/android-trick-for-stop-video-when-leave.html
精彩评论