Android分组子级的不同视图布局之BUG奇遇记

最近在使用按日期分类列表,二级条目可能不一样,于是就想到了ExpandableListView。

ExpandableListView的布局显示分割线问题:

  1.  <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要求也一样。看源码:

  1. /**
         * 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奇遇记的更多相关文章

  1. Android开发-Listview中显示不同的视图布局

    1. 使用场景 在重写ListView的BaseAdapter时,我们常常在getView()方法中复用convertView,以提高性能.convertView在Item为单一的同种类型布局时,能够 ...

  2. css flew 布局 解决父元素高度不固定,子级居中。

    给父级添加 display: flex; justify-content: flex-start; align-items: center; 子级里的内容永远居中

  3. 【Android UI】Android开发之View的几种布局方式及实践

    引言 通过前面两篇: Android 开发之旅:又见Hello World! Android 开发之旅:深入分析布局文件&又是“Hello World!” 我们对Android应用程序运行原理 ...

  4. Android 开发:view的几种布局方式及实践

    View的几种布局显示方法,以后就不会在针对布局方面做过多的介绍.View的布局显示方式有下面几种:线性布局(Linear Layout).相对布局(Relative Layout).表格布局(Tab ...

  5. 【转】Android开发学习笔记:5大布局方式详解

    Android中常用的5大布局方式有以下几种: 线性布局(LinearLayout):按照垂直或者水平方向布局的组件. 帧布局(FrameLayout):组件从屏幕左上方布局组件. 表格布局(Tabl ...

  6. Android开发:View的几种布局及实践

    引言 View的布局显示方式有下面几种:线性布局(Linear Layout).相对布局(Relative Layout).表格布局(Table Layout).网格视图(Grid View).标签布 ...

  7. Android使用Mono c#分段列表视图

    下载source code - 21.7 KB 你想知道如何把多个ListView控件放到一个布局中,但是让它们在显示时表现正确吗 多个列表项?你对它们正确滚动有问题吗?这个例子将向你展示如何组合单独 ...

  8. [Unity3D]巧妙利用父级子级实现Camera场景平面漫游

    本文系作者原创,转载请注明出处 入门级的笔者想了一上午才搞懂那个欧拉角的Camera旋转..=.= 在调试场景的时候,每次都本能的按下W想前进,但是这是不可能的(呵呵) 于是便心血来潮想顺便添加个Ke ...

  9. Android四大组件之Activity(活动)及其布局的创建与加载布局

    Android四大组件之Activity(活动)及其布局的创建与加载布局 什么是Activity ? 活动(Activity)是包含用户界面的组件,主要用于和用户进行交互的,一个应用程序中可以包含零个 ...

随机推荐

  1. 比较jquery中的after(),append(),appendTo()方法

    html页面: <p id="myp1">我的兴趣爱好是:</p> <button id="b1">after函数</ ...

  2. 阿里云oss怎么上传文件夹

    最近公司在做工程项目,实现文件夹云存储上传 网上找了很久,发现很多项目都存在一些问题,但还是让我找到了一个成熟的项目. 工程: 对项目的文件夹云存储上传功能做出分析,找出文件夹上传的原理,对文件夹的云 ...

  3. java.io.IOException: Can't read [\jre\lib\rt.jar]

    [proguard] java.io.IOException: Can't read [F:\e\java\jdk1.8.0_101\jre\lib\rt.jar] (Can't process cl ...

  4. CreateEvent( )——创建事件函数

    /*************************************************************************************************** ...

  5. _编程语言_C++_setw()

    C++ 中使用setw(int n) 来控制输出间隔. 例如: cout<<)<<'a'<<endl;//s与a之间有7个空格,setw()只对后面紧跟的输出产生作 ...

  6. c# json转换成dynamic对象,然后在dynamic对象中动态获取指定字符串列表中的值

    using Newtonsoft.Json;using System;using System.Collections.Generic;using System.Linq;using System.T ...

  7. android根据图片路径显示图片

    首先根据图片路径先创建一个文件path为图片路径:然后判断文件是否存在,如果存在,将图片显示出来. File file = new File(path); ImageView img = (Image ...

  8. linux-python在vim下的自动补全功能

    linux-python在vim下的自动补全功能 安装配置: wget https://github.com/rkulla/pydiction/archive/master.zipunzip -q m ...

  9. Linux查看History记录加时间戳小技巧

    Linux查看History记录加时间戳小技巧 熟悉bash的都一定知道使用history可以输出你曾经输入过的历史命令,例如[root@servyou_web ~]# history | more ...

  10. 【文文殿下】P3737 [HAOI2014]遥感监测

    题解 显然可以把每个观测点,认为是x轴上的一段区间.问题就转换为了:对于x轴上的若干个区间,选取尽可能少的点,使得所有区间都有至少一个点. 这是一个相当经典的贪心问题. 代码如下: #include& ...