2
I have a TabActivity
with two Tabs
, both have a VideoView
(Man|Woman). When I start one of the Tabs
and then switch to the other, the video of the first still running underneath the other video. How can I fix this?
Follow the code I’m using:
Tabactivity
public class BarraTabActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TabHost tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec("homem").setIndicator("Homem").setContent(new Intent(this, HomemActivity.class)));
tabHost.addTab(tabHost.newTabSpec("mulher").setIndicator("Mulher").setContent(new Intent(this, MulherActivity.class)));
tabHost.setCurrentTab(0);
}
Activity Man
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_homem);
String path = "www.exemplo.com";
Uri uri = Uri.parse(path);
videoView = (VideoView) findViewById(R.id.vwHomem);
videoView.setMediaController(new MediaController(this));
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();
}
Activity Woman
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mulher);
String path = "www.exemplo.com";
Uri uri = Uri.parse(path);
videoView = (VideoView) findViewById(R.id.vwMulher);
videoView.setMediaController(new MediaController(this));
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();
}
Layout (For Man or Woman is the same, only the names change)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView
android:id="@+id/vwHomem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2sp"
android:layout_marginRight="2sp"
android:layout_marginTop="2sp"/>
</RelativeLayout>
Thanks for the reply, but it did not work, the video continues one over the other, even being in different activitys.
– Luiz Rogério Scudeletti