我的活動佈局如下所示。基本上我有一個左側的列表視圖菜單和兩個視頻切換,這取決於用戶點擊哪個菜單項。一個videoview被另一個videoview屏蔽
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_system_status"
android:title="@string/system_status"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="4">
<ListView
android:id="@+id/list_video_feed"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
</LinearLayout>
<LinearLayout
android:id="@+id/linear_layout_live_video"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1">
<VideoView
android:id="@+id/video_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/linear_layout_video_gallery"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1">
<Gallery
android:id="@+id/gallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<VideoView
android:id="@+id/archived_video_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
在我的代碼,如果我想打從視圖視頻,而無需畫廊,我隱藏其他。
linearLayoutVideoGallery.setVisibility(GONE);
linearLayoutLiveVideo.setVisibility(VISIBLE);
playVideo();
問題是,archived_video_view停留在頂部,只有畫廊隱藏。有小費嗎?如果您需要任何其他信息,請告知我。謝謝!
編輯:這是我的if語句,用於選擇onCreate()內的菜單項。希望這會有所幫助。當我點擊位置== 1,然後位置== 2時,畫廊消失了,但是archived_video_view仍然處於暫停狀態,所以我只能看到video_view的最上面一個畫廊,就是畫廊過去的位置。
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
if (position==1) { //video gallery list item has been pressed
vvLive.stopPlayback();
linearLayoutLiveVideo.setVisibility(GONE);
linearLayoutVideoGallery.setVisibility(VISIBLE);
playArchivedVideo();
}
else if (position == 2) { //live video list item has been pressed
vvArchive.stopPlayback();
linearLayoutVideoGallery.setVisibility(GONE);
linearLayoutLiveVideo.setVisibility(VISIBLE);
playLiveVideo();
}
}
});
您是否完全確定您正在使用正確的ID來獲取linearLayoutVideoGallery和linearLayoutLiveVideo視圖? – slund 2011-04-15 21:26:08
是的。當我點擊視頻庫,然後點擊直播視頻時,頂部的水平畫廊就會隱藏起來,我只能看到現場視頻播放的那條小條,因爲存檔視頻仍處於前臺。我用switch語句添加了一些額外的代碼。謝謝。 – yellavon 2011-04-18 14:47:32