gpt4 book ai didi

android-layout - 用xml中的android上的静态元素定义 ListView ?

转载 作者:行者123 更新时间:2023-12-03 08:46:27 25 4
gpt4 key购买 nike

我想创建一个片段,它将静态菜单显示为列表中的一组行。

我喜欢在 tableview 中使用静态单元格的 iOS 方法。我怎样才能在 android 中实现这一点(所以不需要代码来定义元素,只需要 xml)

接下来有什么常规方法可以在xml中定义静态元素

(伪代码)

list_view.xml

<List view>
- use element my_row with onclick=row1_clicked and title="row 1"
- use element my_row with onclick=row2_clicked and title="row 2"
- use element my_row with onclick=row3_clicked and title="row 3"
- use element my_row with onclick=row4_clicked and title="row 4"
</List view>

my_row.xml

<My Row>
- text field (title should go here)
- on click (on click should go here)
</My Row>

所以基本上我想在列表中“包含”行并在 xml 级别(没有代码)进行。

最佳答案

不幸的是,禁止通过 xml 定义 ListView 。相反,需要使用适配器。

关于android-layout - 用xml中的android上的静态元素定义 ListView ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13864260/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com