Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将页脚视图添加到选项卡主机Android_Android_Android Listview_Android Tabhost_Footer - Fatal编程技术网

将页脚视图添加到选项卡主机Android

将页脚视图添加到选项卡主机Android,android,android-listview,android-tabhost,footer,Android,Android Listview,Android Tabhost,Footer,我想添加一个页脚视图,一个列表视图中加载的元素计数器。我想知道我把页脚视图放在哪里了。我的listview中已经有了一个,我想我不能把它放在那里,因为我希望它一直都是可见的,而不是像我现在这样深入到它的底部 代码: 列表视图: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_

我想添加一个页脚视图,一个列表视图中加载的元素计数器。我想知道我把页脚视图放在哪里了。我的listview中已经有了一个,我想我不能把它放在那里,因为我希望它一直都是可见的,而不是像我现在这样深入到它的底部

代码:

列表视图:

<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>     

怎么样

从文件:

添加固定视图以显示在列表底部。如果添加页脚视图 如果多次调用,视图将按其显示的顺序显示 补充。如果需要,使用此调用添加的视图可以获得焦点

注意:在调用setAdapter之前调用此函数。这就是ListView可以做到的 将提供的游标与一个也将用于标题的游标包装在一起 和页脚视图


如果将具有匹配父级宽度和高度的FrameLayout放置在线性布局中,所有内容将隐藏在屏幕之外

有两种表单可添加该页脚:

首先,使用以下尺寸设置framelayout:

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


第二,如果要将页脚添加到内容上方,请使用RelativeLayout并将所有内容设置为“其他”,然后使用layout\u alignParentBottom=true添加页脚。如果希望页脚与内容在一起,请在最后一个视图下方添加页脚。

这可能会对您有所帮助

创建名为
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>
这将给你一个页脚。你可以改变重力,使它也成为一个标题。
我知道您要求使用标签,但我想我应该与您共享,也许这对您有好处。

我已经将页脚视图设置为列表视图,而且,该解决方案无法满足我的需要
 <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>