我可以在布局/合并布局中添加布局吗?
如果可能的话,如何在分配给 SimpleCursorAdapter (“ondemandandautomatic_authorize”)的布局上方添加一个“标题”,并在 ListView 下方添加一个按钮?
SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this,
R.layout.ondemandandautomatic_authorize, mContacts,
new String[] { ContactsContract.Contacts.DISPLAY_NAME },
new int[] { R.id.contactLabel });
setListAdapter(mAdapter);
我现在在我的活动中显示的是:
<AppName>
<ckbx1><ckbx2><ckbx3><TextView (ContactName)>
...(repeating the line above for each contact)
但我想要的是:
<AppName>
<TextView1><TextView2><TextView3><TextView4>
<ckbx1> <ckbx2> <ckbx3> <TextView (ContactName)>
...(repeating the line above for each contact)
<Button>
可能吗?
If it's possible, how can I add a "header" above the layout I've got assigned to my SimpleCursorAdapter ("ondemandandautomatic_authorize"), and a button below the ListView?
SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this,
R.layout.ondemandandautomatic_authorize, mContacts,
new String[] { ContactsContract.Contacts.DISPLAY_NAME },
new int[] { R.id.contactLabel });
setListAdapter(mAdapter);
What I've got displaying now in my Activity is:
<AppName>
<ckbx1><ckbx2><ckbx3><TextView (ContactName)>
...(repeating the line above for each contact)
But what I want is:
<AppName>
<TextView1><TextView2><TextView3><TextView4>
<ckbx1> <ckbx2> <ckbx3> <TextView (ContactName)>
...(repeating the line above for each contact)
<Button>
Possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 Listviewinstance.addHeaderView(viewtobeadded) 作为列表标题部分和
Listviewinstance.addFooterView(buttontobeadded) 用于页脚部分底部的按钮。
请确保在列表视图上设置适配器之前必须完成这些页脚和页眉添加操作。
Use Listviewinstance.addHeaderView(viewtobeadded) for list header part and
Listviewinstance.addFooterView(buttontobeadded) for the button at the bottom of the footer part.
Please make sure that these footer and header addition things must be done before setting adapter on your listview.
如果您希望按钮位于列表底部,您可能需要向 ListView 添加页脚,这里是 javadoc。
getListView().addFooterView(new Button(...));
这必须在
setListAdapter(mAdapter);
之前完成。You probably want to add a Footer to the ListView if you want the Button at the bottom of list, here is the javadoc.
getListView().addFooterView(new Button(...));
This HAS to be done before
setListAdapter(mAdapter);
.