• 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);
  • 相关阅读:
    获取项目路径
    Form提交时隐藏Token验证
    属性路由参数约束
    使用Cookie来统计浏览次数,当天重复刷新不增加
    图片上传预览 支持html5的浏览器
    icheck.min.js 选中效果
    bootstrap-modal.js 居中问题
    七十二、SAP中内表的修改,添加条件语句,多条目修改
    七十一、SAP中内表的修改,改一行数据,或一行的某个字段
    七十、SAP中内表批量指定位置插入
  • 原文地址:https://www.cnblogs.com/denluoyia/p/9954184.html
Copyright © 2020-2023  润新知