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)是包含用户界面的组件,主要用于和用户进行交互的,一个应用程序中可以包含零个 ...
随机推荐
- 小论文matlab作图技巧
小论文matlab作图技巧 编辑->复制选项 编辑->图形属性 图中右击->字型 编辑->复制图片,即可. 效果: 宽:5.9高: 7.91
- AngularJS监听数组变化
我们在使用angualr的监听时候,业务的需要我们会去监听一个数组的某一个值得变化,再写逻辑代码.然而我们在使用$scope.$watch("",function(){ })时候会 ...
- 解决编译错误:cc: Internal error: Killed (program cc1)
错误现象: cc: Internal error: Killed (program cc1) ... 大体上是因为内存不足,临时使用交换分区来解决吧 sudo mkswap /swapfile sud ...
- _技巧_SublimeText_打开文件乱码解决
macOS属于Unix分支,默认使用UTF-8编码,当从Window 或者其他Linux 或 Unix系统 拷贝文件过来,由于Window系统使用GBK或者GB2312中文编码,所以会出现乱码现象. ...
- html5之range
第一次以这种方式做笔记,希望可以加强自己对新知识的理解,更希望能得到更多朋友的指正. 言归正传: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 ...
- java锁类型
转载链接在每个锁类型后边 线程锁类型 1.自旋锁 ,自旋,jvm默认是10次吧,有jvm自己控制.for去争取锁 锁作为并发共享数据,保证一致性的工具,在JAVA平台有多种实现(如 synchroni ...
- input.php
<?php /** * */ class Input { function get($index = NULL, $xss_clean = FALSE) { if($index == NULL ...
- user_agent
public function getipinfo($ip) { $res = '其他'; $url = "http://int.dpool.sina.com.cn/iplookup/ipl ...
- day09_雷神_模块二
day09 序列化之json 之前我们学习过用eval内置方法可以将一个字符串转成python对象,不过,eval方法是有局限性的,对于普通的数据类型,json.loads和eval都能用,但遇到特殊 ...
- A - Playground
My kid's school cleared a large field on their property recently to convert it into a playing area. ...