如何将按钮放置在 ListView 的末尾?

发布于 2024-12-29 12:14:33 字数 1342 浏览 2 评论 0原文

我的布局屏幕有问题。我想要实现的是一个具有多行的列表视图,每行都有一个图像视图和两个 EditText 视图。在最后一行的底部,应该有两个按钮(提交取消

我已经设法使该行成功工作,但是在添加按钮时我不断出现错误。数据是从游标读取的,我发现这使事情变得更加复杂。

有没有办法在 contentView 布局中使用行布局?

这是 XML:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout 
        xmlns:android="http://schemas.android.com/apk/res/android" 
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
   <ImageView
    android:id="@+id/logo"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_alignParentTop="true"
    android:layout_alignParentBottom="true"
    android:src="@drawable/gm" >
</ImageView>

<EditText
    android:id="@+id/firstLine"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:text="email"        
    >
</EditText>

<EditText
    android:id="@+id/secondLine"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:layout_alignRight="@id/logo"
    android:layout_alignParentRight="true"
    android:layout_below="@id/firstLine"
    android:text="password"  
    >
</EditText></RelativeLayout>

I am having a problem with my layout screen. What I am trying to achieve is a listview with multiple rows, each row having one Image view and two EditText views. At the bottom of the very last row, there should be two buttons (Submit & Cancel)

I have managed to get the row working successfully, but when adding the buttons I keep getting errors. The data is being read in from a cursor, which I find complicates things further.

Is there a way I can use a row layout inside a contentView layout?

Here is the XML:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout 
        xmlns:android="http://schemas.android.com/apk/res/android" 
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
   <ImageView
    android:id="@+id/logo"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_alignParentTop="true"
    android:layout_alignParentBottom="true"
    android:src="@drawable/gm" >
</ImageView>

<EditText
    android:id="@+id/firstLine"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:text="email"        
    >
</EditText>

<EditText
    android:id="@+id/secondLine"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:layout_alignRight="@id/logo"
    android:layout_alignParentRight="true"
    android:layout_below="@id/firstLine"
    android:text="password"  
    >
</EditText></RelativeLayout>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

手长情犹 2025-01-05 12:14:33

使用底部按钮创建一个单独的布局,并将其添加为 页脚。顺便说一句,您还可以添加标题。

Create a separate layout with the bottom buttons and add it as a footer. You can also add a header btw.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文