java - 如何在 ListView 下方添加 View

标签 java android listview

我在 SO 上发现的主题很少,但它们不是我要搜索的内容。其中之一就是这个Android ListActivity - how to add a view below the ListView?

我知道我可以在 ListView 的页脚放置一个 View (如按钮)。这意味着所需的 View 将在最后一个 View 之后定位自己。

我想知道如何将 View 定位在屏幕的末尾(正下方)。 请检查下面两张图片:

enter image description here

enter image description here

我想在 Java 代码中执行此操作。有任何想法吗?

最佳答案

试试下面的代码

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

</ListView>

<Button
    android:id="@+id/button1"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:text="Button" />

关于java - 如何在 ListView 下方添加 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15815232/

相关文章:

java - 使用 JDB(或类似工具)调试 ASM 生成的字节码

java - try catch block 中的 Mockito Thread.class 异常不会提高覆盖率

java - Selenium - 不一致的 StaleElementReference 错误

android - 为什么项目上下文菜单没有显示在 ListView 中

java - 为什么我的水平回收 View 不会在 fragment 中滚动

java - 尝试使用 MIME 发送 "alternative"但它也出现在有能力的邮件客户端中

AndroidHttpClient Nullpointerexception 调用 android.net.http.AndroidHttpClient.isMmsRequest

android - 如何从非 Activity 类(uiautomator 类的 Junit)调用 Activity 类中的方法

android - 支持库 v25.0.0 动画中的底部导航 View ?

json - 如何在Flutter ListView构建期间测试json属性是否存在