Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.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 ListView底部的按钮仅在Eclipse设计器中工作_Android_Android Layout - Fatal编程技术网

Android ListView底部的按钮仅在Eclipse设计器中工作

Android ListView底部的按钮仅在Eclipse设计器中工作,android,android-layout,Android,Android Layout,我试图在ListActivity的底部放置一个按钮。 以下内容在Eclipse designer中非常有效,但在我启动手机或AVD的应用程序时就不行了 有什么想法吗 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"

我试图在ListActivity的底部放置一个按钮。 以下内容在Eclipse designer中非常有效,但在我启动手机或AVD的应用程序时就不行了

有什么想法吗

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

    <ListView
        android:id="@+id/list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/btn_New" >
    </ListView>

    <Button
        android:id="@+id/btn_New"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="Button"
        android:layout_alignParentBottom="true" />
</RelativeLayout>

按钮在设计器中正确显示

按钮未出现在我的手机或AVD上

您必须将按钮放在列表之前:

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

<Button
    android:id="@+id/btn_New"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:text="Button"
    android:layout_alignParentBottom="true" />

<ListView
    android:id="@+id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_above="@+id/btn_New" >
</ListView>
</RelativeLayout>


因此,布局充气器可以“查看”列表必须位于顶部的视图。您可以在列表视图中添加页脚。您可以使用本文提供的示例


这完全是我的错。我的活动是扩展SherlockListActivity,而不是SherlockListActivity。所以按钮当然没有显示出来

谢谢你的帮助,
国泰

这没有效果。该按钮仍显示在Eclipse设计器中,但不显示在我的手机或AVD上。是的,我确保从手机和AVD上卸载该应用程序,以验证修改是否确实发生。
View footerView = ((LayoutInflater)      
ActivityContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.footer_layout, null, false);
ListView.addFooterView(footerView);