zoukankan      html  css  js  c++  java
  • 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);
  • 相关阅读:
    python requests 模拟登陆网站,抓取数据
    python 爬取淘宝的模特照片
    vim 和grep 正则表达式相似和区别
    python 读取文件时报错UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal multibyte sequence
    python 正则表达式
    12个球,其中一个和其他的重量不一样,有一个天平,最多几次找出这个球
    25匹马中选出跑得最快的3匹,每次只有5匹马同时跑,最少要比赛几次
    1000瓶药水,1瓶有毒药,几只小白鼠能够找出毒药
    146 LRU Cache
    用两个int值实现读写锁
  • 原文地址:https://www.cnblogs.com/denluoyia/p/9954184.html
Copyright © 2011-2022 走看看