android - Activity 上的简单确定按钮

标签 android android-layout android-listview

我的 Activity 中有 ListView 组件,我设法使用 Activity 的布局 xml 文件在其下方添加按钮。但问题是,在横向模式下,按钮不可见,因为 ListView 很长。

那么有没有办法添加简单的 OK 按钮来关闭当前 Activity ,但在横向或纵向模式下都可见?

我知道这个页面listview-voggela但是实现起来有点复杂,而且我不是安卓专家。所以我正在寻找简单的解决方案。谢谢

最佳答案

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

<Button android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:id="@+id/okbutton"
    android:text="@string/hello" android:layout_alignParentBottom="true" />

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

</RelativeLayout>

关于android - Activity 上的简单确定按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18057312/

相关文章:

java - 海量数据android的tablelayout

android - 判断屏幕是否有圆角

java - 从名称和索引中选择图像

具有可变数量的 subview 的android listview行

android - 如何更改 Android Jetpack Compose 中的 OutlineTextField 边框宽度?

java - onCreate 中声明的随机整数

java - 是否可以扩展 Button 类并让它实现自己的 OnClick 监听器?

Android AlertDialog按钮定位

android - ListView 中的 Spinner 问题

java - 无法使用 ArrayList<HashMap<String,?>>> 填充 listView