2

リストビューに読み込まれた要素のカウンターであるフッタービューを追加したいと思います。フッタービューをどこに置くべきか知りたいです。私はすでにリストビューに1つ持っていますが、私が持っているもののように一番下に到達したときではなく、常に表示したいので、そこに置いてはいけないと思います。

コード:

リストビュー:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:orientation="vertical">

<ListView
    android:id="@+id/lista"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:stackFromBottom="false"
    android:transcriptMode="normal"
    />
</LinearLayout>

タブのコード:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainTabActivity" >
<TabHost
    android:id="@android:id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical|fill_vertical|fill_horizontal" >
        </TabWidget>
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
            <LinearLayout
                android:id="@+id/tab1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >                   
                <ListView
                    android:id="@+id/lista"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:stackFromBottom="false"
                    android:transcriptMode="normal"
                    />
            </LinearLayout>
            <LinearLayout
                android:id="b"
            </LinearLayout>

            <LinearLayout
                android:id="c"
            </LinearLayout>                
            <LinearLayout
                android:id="d"
            </LinearLayout>                            
        </FrameLayout>
    </LinearLayout>                      
</TabHost>     

私はこれを持っています: http://imageshack.us/photo/my-images/23/6a3t.jpg/

そして、私はこれが欲しいです: http://imageshack.us/photo/my-images/809/kesm.jpg/

4

3 に答える 3

2

幅と高さが match_parent の FrameLayout を LinearLayout 内に配置すると、すべてのコンテンツが画面の外に隠れます。

そのフッターを追加する 2 つのフォームがあります。

まず、このサイズでフレーム レイアウトを設定します。

<FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

2 つ目は、RelativeLayout を使用してすべてのコンテンツを他のコンテンツの下に設定し、コンテンツの上にフッターを追加する場合は layout_alignParentBottom = true でフッターを追加するか、フッターをコンテンツと共に配置する場合は最後のビューの下にフッターを追加します。

于 2013-07-26T09:11:44.450 に答える
0

多分これはあなたを助けることができます。

というファイルを作成し、footer.xml このコードを追加します

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="40dp"
    android:layout_gravity="bottom"
    android:gravity="bottom"
 android:layout_weight=".15"
    android:orientation="horizontal"
    android:background="@drawable/bckkaup" >
    <ImageView
        android:id="@+id/lborder"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".14"
        android:background="@drawable/action_bar_left_button"
        android:src="@drawable/over_9"
        android:scaleType="fitXY" />
    <ImageView
        android:id="@+id/unknown"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".14"
        android:background="@drawable/action_bar_left_button"
        android:src="@drawable/cartoon_9"
        android:scaleType="fitXY" />

    <ImageView
        android:id="@+id/open"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".14"
        android:background="@drawable/action_bar_left_button"
        android:src="@drawable/gallery_9"
        android:scaleType="fitXY"
        android:hapticFeedbackEnabled="true"
        android:soundEffectsEnabled="true"

        />

    <View
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="0.03" 
        android:src="@drawable/action_bar_right_button"
        android:background="@drawable/action_bar_left_button"
        />

    <ImageView
        android:id="@+id/opencam"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".14"
        android:background="@drawable/action_bar_left_button"
        android:src="@drawable/camera_9"
        android:scaleType="fitXY"
        android:hapticFeedbackEnabled="true"
        android:soundEffectsEnabled="true"
        />
    <ImageView
        android:id="@+id/color"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".14"
        android:background="@drawable/action_bar_left_button"
        android:src="@drawable/stylish_9"
        android:scaleType="fitXY" />
        <ImageView
        android:id="@+id/rborder"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="@drawable/action_bar_left_button"
        android:src="@drawable/frame_9"
        android:layout_weight=".14" 
        android:scaleType="fitXY"/>


</LinearLayout>

そして、main layout このコードを追加してください

 <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="40dp"
    android:id="@+id/down"
    android:layout_alignParentBottom="true" >

    <include
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        layout="@layout/footer" >

    </include>
</LinearLayout>    

これにより、フッターが表示されます。重力を変更してヘッダーにすることもできます。あなたがタブを求めていることは知っていますが、それをあなたと共有する必要があると思いました.

于 2013-07-26T10:18:36.473 に答える
0

どうListView.addFooterViewですか?

ドキュメントから:

リストの下部に表示される固定ビューを追加します。addFooterView が複数回呼び出された場合、ビューは追加された順序で表示されます。この呼び出しを使用して追加されたビューは、必要に応じてフォーカスを取得できます。

注: setAdapter を呼び出す前にこれを呼び出します。これは、ListView が提供されたカーソルを、ヘッダー ビューとフッター ビューも考慮したカーソルでラップできるようにするためです。

于 2013-07-26T09:00:52.957 に答える