如何preVIEW Android的ListView中自定义行头布局 [英] How to preview Android ListView with custom row and header layout
问题描述
我已经创建了一个自定义布局页眉和行项目很多次,但总是什么惹恼我是Android Studio中的UI preVIEW不显示preVIEW列表视图。显然,因为自定义布局由ListView控件或CursorAdapter的,但什么编程方式加载,如果我想一些如何指定XML页眉和页脚的布局,这样我可以看到一个preVIEW。任何一个知道如何做到这一点?
I have created a list view with a custom layout for the header and rows items many times but what always annoys me is the UI preview in Android Studio does not show a preview. Obviously because the custom layouts are loaded programmatically by the ListView or CursorAdapter but what if I wanted to some how specify a header and footer layout in xml so that I could see a preview. Any one know how to do that?
推荐答案
您可以使用 工具:列表项
。只需添加工具命名空间布局的根
You can use tools:listitem
. Just add the tools namespace in the root of the layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
(...)
,然后在你的ListView设置列表项的布局
and then in your ListView set your list item layout
<ListView
android:id="@+id/mylistView"
tools:listitem="@layout/my_list_item"
(...)
也可以设置页眉/页脚 listheader
/ listfooter
。
Is also possible to set header/footer with listheader
/listfooter
.
这篇关于如何preVIEW Android的ListView中自定义行头布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!