0

我已经阅读了http://developer.android.com/resources/articles/layout-tricks-stubs.html,它解释了如何使用 viewtub 作为布局的惰性包含。

这在我拥有的简单列表视图上运行良好,但是当我尝试在我的实际选项卡式布局中使用它时,一旦选项卡获得任何真实内容,它就会消失。

我已将所有选项卡和选项卡主机设置为使用 wrap_content 作为高度(以免将存根推开)

有没有人使用带有标签视图的存根?诀窍是什么?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical" android:layout_width="fill_parent"
 android:layout_height="fill_parent">
 <TabHost android:id="@android:id/tabhost" android:layout_width="fill_parent"
  android:layout_height="wrap_content">
  <LinearLayout android:orientation="vertical"
   android:layout_width="fill_parent" android:layout_height="wrap_content">
   <TabWidget android:id="@android:id/tabs"
    android:layout_width="fill_parent" android:layout_height="wrap_content" />
   <FrameLayout android:id="@android:id/tabcontent"
    android:layout_width="fill_parent" android:layout_height="wrap_content">
    <ListView android:id="@+id/discqueue" android:layout_width="fill_parent"
     android:layout_height="wrap_content" />
    <ListView android:id="@+id/instantqueue"
     android:layout_width="fill_parent" android:layout_height="wrap_content" />
   </FrameLayout>
   <ViewStub android:id="@+id/stub_navigate"
    android:inflatedId="@+id/panel_navigate" android:layout="@layout/pagination_bar"

    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:layout_gravity="bottom" />
  </LinearLayout>
 </TabHost>
</LinearLayout>
4

1 回答 1

2

弄清楚了!

他们在开发者网站上没有提到的技巧是,对于列表/网格类型的动态视图,您实际上希望将现有视图与任何存根合并,而不是像这样将存根插入到您的视图中;

<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">

<include android:id="@+id/cell3" layout="@layout/queue_man" android:layout_height="40dp" android:layout_gravity="bottom" />

    <ViewStub
        android:id="@+id/stub_navigation"
        android:inflatedId="@+id/panel_navigation"

        android:layout="@layout/pagination_bar"

        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom" />

</merge>

这当然会让纸杯蛋糕和甜甜圈的用户望而却步。

于 2010-01-30T14:58:36.777 回答