Android 无法在列表视图下显示按钮

Android 无法在列表视图下显示按钮,android,listview,user-interface,android-arrayadapter,Android,Listview,User Interface,Android Arrayadapter,我正在从API获取数据,并制作一个Android新闻应用程序。每页有X条新闻文章。假设每页10篇文章。所以我使用ListView和ArrayAdapter来显示第一页上的所有文章。我想在第10篇文章的末尾,在listView下面,它说的更多或者类似于加载下一页包含接下来10篇文章的内容。现在我正在处理UI,而按钮没有显示在listView下面 我尝试了以下场景: Layout_alignparentBotton:按钮使用Layout_alignparentBotton卡在parentBottom

我正在从API获取数据,并制作一个Android新闻应用程序。每页有X条新闻文章。假设每页10篇文章。所以我使用ListView和ArrayAdapter来显示第一页上的所有文章。我想在第10篇文章的末尾,在listView下面,它说的更多或者类似于加载下一页包含接下来10篇文章的内容。现在我正在处理UI,而按钮没有显示在listView下面

我尝试了以下场景:

Layout_alignparentBotton:按钮使用Layout_alignparentBotton卡在parentBottom上,但列表可滚动,并位于按钮下方,因为按钮固定,但列表可滚动。预期结果

下面的布局:我尝试了下面的布局,并给出了列表视图的id。然后按钮根本不显示。我不知道为什么。我想这是可能的解决办法,但我想我做错了什么

以下是我的XML:

<?xml version="1.0" encoding="utf-8"?>
<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:orientation="vertical">



    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" />


    <Button
        android:id="@+id/moreButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/list"
        android:text="More" />

</RelativeLayout>
如果这有助于列表中单个项目的XML,那么listView就是这样做的:

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/customListViewID"
        android:background="@drawable/background_shape_adapter"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/newsThumbnailImage"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:scaleType="centerCrop" />

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="3"
            android:orientation="vertical"
            android:paddingStart="10dp"
            android:paddingTop="10dp">

            <TextView
                android:id="@+id/titleNewsTextView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:maxLines="3"
                android:text="Title Of News"
                android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small"
                android:textColor="#000" />

            <TextView
                android:id="@+id/newsSnippetTextView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:maxLines="2"
                android:text="Content Snippet"
                android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small.Inverse"
                android:textColor="@color/black_overlay" />
        </LinearLayout>
    </LinearLayout>


</LinearLayout>

尝试在第一个XML文件中使用垂直方向的线性布局,而不是相对性布局。

使用带有alignParentBottom的按钮,将其设置为不可见,当listview到达终点时,显示它

private int preLast;
// Initialization stuff.
yourListView.setOnScrollListener(this);

// ... ... ...

@Override
public void onScroll(AbsListView lw, final int firstVisibleItem,
    final int visibleItemCount, final int totalItemCount)
{

switch(lw.getId()) 
{
    case R.id.your_list_id:     

        // Make your calculation stuff here. You have all your
        // needed info from the parameters of this function.

        // Sample calculation to determine if the last 
        // item is fully visible.
        final int lastItem = firstVisibleItem + visibleItemCount;

        if(lastItem == totalItemCount)
        {
            if(preLast!=lastItem)
            {
                bottomButton.setVisibility(View.VISIBLE);
                preLast = lastItem;
            }
        }
}
}

线性布局不允许下面的布局。删除下面的布局,它是不需要的。嗯,我刚刚在我的环境中测试了它,它正在工作。我添加了一个ScrollView以启用滚动,并删除了ListView上的android:orientation=vertical。好吧,也许当您自定义列表视图并用一个图像和两个文本视图创建一个列表时,它就不同了,并且组合不起作用。我试着把它改成线性布局,但对我不起作用。无论如何,谢谢。当使用别人的答案时,请参考别人的答案。