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);
  • 相关阅读:
    jQuery learning
    【转】PHP技巧汇总:提高PHP性能的53个技巧
    [转]浅谈JavaScript编程
    英语常用口语
    中文数字转换为阿拉伯数字
    [ASP.NET MVC 3.0]JsonValueProviderFactory讓Action接收Json更輕鬆
    xapian_binaries
    查询sql数据库中的所有表和表描述
    scrollTop获取不到值的解决方法
    iframe操作ie,firefox兼容
  • 原文地址:https://www.cnblogs.com/denluoyia/p/9954184.html
Copyright © 2011-2022 走看看