Pinned Header Expandable ListView

    Rating: ★★★★☆
    View: 205
    Download: 73
    Từ khóa:

    Cài Đặt:

    public interface OnHeaderUpdateListener {
    
            public View getPinnedHeader();
    
            public void updatePinnedHeader(View headerView, int firstVisibleGroupPos);
        }
    
        public interface OnGiveUpTouchEventListener {
            public boolean giveUpTouchEvent(MotionEvent event);
        }
    @Override
        public View getPinnedHeader() {
            View headerView = (ViewGroup) getLayoutInflater().inflate(R.layout.group, null);
            headerView.setLayoutParams(new LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    
            return headerView;
        }
    
        @Override
        public void updatePinnedHeader(View headerView, int firstVisibleGroupPos) {
            Group firstVisibleGroup = (Group) adapter.getGroup(firstVisibleGroupPos);
            TextView textView = (TextView) headerView.findViewById(R.id.group);
            textView.setText(firstVisibleGroup.getTitle());
        }
    
        @Override
        public boolean giveUpTouchEvent(MotionEvent event) {
            if (expandableListView.getFirstVisiblePosition() == 0) {
                View view = expandableListView.getChildAt(0);
                if (view != null && view.getTop() >= 0) {
                    return true;
                }
            }
            return false;
        }

     

    loading Đang tải...

    template được ưa chuộng