Мой макет активности показан ниже.По сути, у меня есть меню списка просмотра слева и два видеообмена, между которыми я переключаюсь, в зависимости от того, какой элемент меню нажимает пользователь.
<?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 остается сверху, и скрывается только галерея.Какие-нибудь советы?Дайте мне знать, если вам нужна дополнительная информация.Спасибо!
EDIT : Вот мое утверждение if для выбора пунктов меню внутри onCreate ().Надеюсь, это поможет.Когда я нажимаю position == 1, а затем postion == 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();
}
}
});