Android分组子级的不同视图布局之BUG奇遇记
Android分组子级的不同视图布局之BUG奇遇记
最近在使用按日期分类列表,二级条目可能不一样,于是就想到了ExpandableListView。
ExpandableListView的布局显示分割线问题:
<ExpandableListView
android:id="@+id/expandableListView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:childDivider="#ededed"
android:divider="#ededed"
android:dividerHeight="10dp"
android:listSelector="@color/transparent" />
childDivider:二级条目的分割线 (可以是drawable或color)
divider:父级条目的分割线 (可以是drawable或color)
dividerHeight:分割线的高度
适配器的BaseExpandableListAdapter中需要注意的getChildType()类型需要从0~getChildTypeCount()-1;同理getGroupType要求也一样。看源码:
/**
* Get the type of child View that will be created by
* {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
* for the specified child item.
*
* @param groupPosition the position of the group that the child resides in
* @param childPosition the position of the child with respect to other children in the group
* @return An integer representing the type of child View. Two child views should share the same
* type if one can be converted to the other in
* {@link android.widget.ExpandableListAdapter#getChildView(int, int, boolean, View, ViewGroup)}
* Note: Integers must be in the range 0 to {@link #getChildTypeCount} - 1.
* {@link android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE} can also be returned.
* @see android.widget.Adapter#IGNORE_ITEM_VIEW_TYPE
* @see #getChildTypeCount()
*/
int getChildType(int groupPosition, int childPosition);
Android分组子级的不同视图布局之BUG奇遇记的更多相关文章
- Android开发-Listview中显示不同的视图布局
1. 使用场景 在重写ListView的BaseAdapter时,我们常常在getView()方法中复用convertView,以提高性能.convertView在Item为单一的同种类型布局时,能够 ...
- css flew 布局 解决父元素高度不固定,子级居中。
给父级添加 display: flex; justify-content: flex-start; align-items: center; 子级里的内容永远居中
- 【Android UI】Android开发之View的几种布局方式及实践
引言 通过前面两篇: Android 开发之旅:又见Hello World! Android 开发之旅:深入分析布局文件&又是“Hello World!” 我们对Android应用程序运行原理 ...
- Android 开发:view的几种布局方式及实践
View的几种布局显示方法,以后就不会在针对布局方面做过多的介绍.View的布局显示方式有下面几种:线性布局(Linear Layout).相对布局(Relative Layout).表格布局(Tab ...
- 【转】Android开发学习笔记:5大布局方式详解
Android中常用的5大布局方式有以下几种: 线性布局(LinearLayout):按照垂直或者水平方向布局的组件. 帧布局(FrameLayout):组件从屏幕左上方布局组件. 表格布局(Tabl ...
- Android开发:View的几种布局及实践
引言 View的布局显示方式有下面几种:线性布局(Linear Layout).相对布局(Relative Layout).表格布局(Table Layout).网格视图(Grid View).标签布 ...
- Android使用Mono c#分段列表视图
下载source code - 21.7 KB 你想知道如何把多个ListView控件放到一个布局中,但是让它们在显示时表现正确吗 多个列表项?你对它们正确滚动有问题吗?这个例子将向你展示如何组合单独 ...
- [Unity3D]巧妙利用父级子级实现Camera场景平面漫游
本文系作者原创,转载请注明出处 入门级的笔者想了一上午才搞懂那个欧拉角的Camera旋转..=.= 在调试场景的时候,每次都本能的按下W想前进,但是这是不可能的(呵呵) 于是便心血来潮想顺便添加个Ke ...
- Android四大组件之Activity(活动)及其布局的创建与加载布局
Android四大组件之Activity(活动)及其布局的创建与加载布局 什么是Activity ? 活动(Activity)是包含用户界面的组件,主要用于和用户进行交互的,一个应用程序中可以包含零个 ...
随机推荐
- 微信小程序两种滑动方式
竖向滑动: <scroll-view scroll-y="true" style="height: 200rpx;"> <view style ...
- AngularJS实战之cookie的读取
<!DOCTYPE html> <html ng-controller="cookies_controller"> <head> <tit ...
- js 上传文件夹
最近公司做工程项目,实现文件夹上传. 网上找了一天,发现网上很多代码都存在相似问题,最后终于找到了一个符合要求的项目. 工程如下: 这里对项目的文件传输功能做出分析,怎么实现文件夹上传的,如何进行文件 ...
- 笔记本真机安装centos7
突然有一天,想要装linux系统,所以就是去装,网上百度说的都很多,而且说来说去都是那几篇,大同小异,所以想通过自己本次装真机的一些经验提供给各位朋友参考一下. 一安装系统: 1先制作启动盘,用个比较 ...
- bzoj2938(ac自动机)
刚学了ac自动机,去hzwer上找了道练习题: 串是安全的就说明ac自动机不会找到匹配,考虑ac自动机的匹配过程: 我们把val等于1的点删掉和fail指针指向被删掉的点删掉: 如果剩下的图有环,就有 ...
- noip第1课资料
- Hdu2389 Rain on your Parade (HK二分图最大匹配)
Rain on your Parade Problem Description You’re giving a party in the garden of your villa by the sea ...
- js跳转页面方法实现汇总
一.页面之间的跳转传参 1.在页面之间跳转的方式有两种: window.location.href=”test.html?num=10” 地址会改变参数也会被传递但是不会打开新窗口 window. ...
- javascript Object.create()究竟发生了什么
这是我在博客园的第一篇博客,早上看了一个大牛的博客,关于javascript继承的,对于大牛使用Object.create()实现继承的方式觉得点问题,就自己研究了一下,所以就有了这篇帖子. 本帖 ...
- C++动态(显式)调用 C++ dll
1.创建DLL新项目Dll1,Dll1.cpp: extern "C" __declspec(dllexport) const char* myfunc() { return &q ...