timehop / sticky-headers-recyclerview

[UNMAINTAINED] Sticky Headers decorator for Android's RecyclerView
Apache License 2.0
3.74k stars 755 forks source link

Header On Click #166

Closed Alireza-Razavi closed 2 years ago

Alireza-Razavi commented 5 years ago

HeaderOnClick doesn't work for me.

        binding.historyRv.setHasFixedSize(true);
        binding.historyRv.setLayoutManager(new LinearLayoutManager(this));
        adapter = new UserHistoryAdapter(this, tcuList);
        StickyRecyclerHeadersDecoration decoration = new StickyRecyclerHeadersDecoration(adapter);
        adapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
            @Override
            public void onChanged() {
                decoration.invalidateHeaders();
            }
        });
        binding.historyRv.addItemDecoration(decoration);
        binding.historyRv.setAdapter(adapter);
        StickyRecyclerHeadersTouchListener touchListener =
                new StickyRecyclerHeadersTouchListener(binding.historyRv, decoration);
        touchListener.setOnHeaderClickListener(
                (header, position, headerId) -> {
                    showMessage("Header clicked!");
                });
        binding.historyRv.addOnItemTouchListener(touchListener);
wanglaohushiwo commented 5 years ago

You can refer to my project:https://github.com/wanglaohushiwo/StickyHeaderFooterRecyclerView

toha-toha commented 5 years ago

@@###