标签:
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://www.cnblogs.com/wei1228565493/p/5070641.html