Android ListView的addHeaderView注意事项
16lz
2021-01-23
Android ListView的addHeaderView注意事项
addHeaderView(heightView, null, false);
heightView这个view如果是从
View view = mInflater.inflate(R.layout.information_playdata_bottom, null);
layout文件转化过来的,那么这个布局文件必须是ViewGroup的根布局,例如LinearLayout或者
其他Layout,里面可以放置一些View.
如果图省事,比如想要heightView只是个不能选择的普通占位占高度的一个View,那么还是不能省事,应该在如此:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<View
android:layout_width="match_parent"
android:layout_height="30dip" />
</LinearLayout>
addHeaderView(heightView, null, false);
heightView这个view如果是从
View view = mInflater.inflate(R.layout.information_playdata_bottom, null);
layout文件转化过来的,那么这个布局文件必须是ViewGroup的根布局,例如LinearLayout或者
其他Layout,里面可以放置一些View.
如果图省事,比如想要heightView只是个不能选择的普通占位占高度的一个View,那么还是不能省事,应该在如此:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<View
android:layout_width="match_parent"
android:layout_height="30dip" />
</LinearLayout>
更多相关文章
- android checkbox 或RadioButton, textView居左居右布局
- Android 指定(后缀名)格式文件扫描
- 水平布局linerlayout
- 从J2EE转向Android的第七天-----文件管理
- 下载文件
- Android NDK开发之旅16--NDK--文件拆分与合并
- android开发中build.gradle文件详解