zoukankan      html  css  js  c++  java
  • ExpandableListView置顶和子list收放

      private int sign = -1;
      result_list.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
                @Override
                public boolean onGroupClick(ExpandableListView parent, final View v, int groupPosition, long id) {
                    final View view = result_list.getChildAt(0);
                    final int p = groupPosition;
                    if(sign == -1){
                        result_list.expandGroup(groupPosition);
                        scroll(result_list, p, view);
                        sign = groupPosition;
                    }else if(sign == groupPosition){
                        result_list.collapseGroup(sign);
                        sign = -1;
                    }else{
                        result_list.collapseGroup(sign);
                        result_list.expandGroup(groupPosition);
                        scroll(result_list, p, view);
                        sign = groupPosition;
                    }
                    return true;
                }
            });
    
      //控制滑动
        public static void scroll(final ExpandableListView result_list,final int position,final View view){
            new Handler().post(new Runnable() {
                @Override
                public void run() {
                    if (android.os.Build.VERSION.SDK_INT >= 11) {
                        result_list.smoothScrollToPositionFromTop((position - 1),
                                -view.getHeight(), 300);
                    }
                }
            });
        }
  • 相关阅读:
    HTTP协议
    django-两种方式对单表的操作
    模态框对话
    django
    web框架原理
    DNS详解
    jQuery
    初识web框架
    练习:简单主页搭建
    多表查询
  • 原文地址:https://www.cnblogs.com/wei1228565493/p/5070641.html
Copyright © 2011-2022 走看看