0

ビュータブをレイアウトのレイジーインクルードとして使用する方法を説明しているhttp://developer.android.com/resources/articles/layout-tricks-stubs.htmlを読みました。

これは私が持っている単純なリストビューではうまく機能しますが、実際のタブ付きレイアウトで使用しようとすると、タブが実際のコンテンツを取得するとすぐに消えます。

すべてのタブとタブホストを高さとして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 に答える