I have TabActivity
with two Tabs
, in both it has a VideoView
(Man | Woman). When I start one of the Tabs
and then switch to the other, the video of the first still runs under the other video. How can I resolve this?
Here is 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 men or women it's the same, just change the names)
<?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>