定义与XML Android上的静态元素列表视图? [英] Define list view with static elements on android in xml?

查看:239
本文介绍了定义与XML Android上的静态元素列表视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创造条件,显示静态菜单列表中的一组行的片段。

I want to create fragment which would display static menu as a set of rows in a list.

我喜欢iOS的方法,在实现代码如下静态细胞。我怎样才能做到这一点android中(所以不需要code中定义的元素,只是XML)

I like iOS method with static cells in a tableview. How can I achieve this in android (so no code is needed to define elements, just xml)

有没有正规的方式来定义的XML接下来方式静态元素

Is there any regular way to define static elements in xml next way

(伪code)

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级(无code)。

So basically I want to "include" row in list and do it on xml level (without code).

推荐答案

不幸的是,列表视图通过XML定义是被禁止的。需要惹适配器来代替。

Unfortunately, list view definition via xml is forbidden. Mess with adapters is required instead.

这篇关于定义与XML Android上的静态元素列表视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆