Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
132 views
in Technique[技术] by (71.8m points)

Define list view with static elements on android in xml?

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

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)

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

(pseudo-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>

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

question from:https://stackoverflow.com/questions/13864260/define-list-view-with-static-elements-on-android-in-xml

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...