作者:温温 | 来源:互联网 | 2023-05-28 15:02
1> Eugen Pechan..:
my_layout_header.xml
这是列表标题的XML布局.
my_layout.xml
这是主要布局.
代码
现在,您需要将标题布局XML扩展为a View
并将其设置为标题视图ListView
.可以在以下内容中使用以下代码段Activity.onCreate(Bundle)
:
setContentView(R.layout.my_layout);
View header = View.inflate(this, R.layout.my_layout, null);
// where "this" is a context / activity...
ListView list = (ListView)findViewById(android.R.id.list);
list.addHeaderView(header, null, false); // header will not be clickable
// ... whatever else you need to do AFTER you set a header (a bug before KITKAT) ...