1

I noticed that SuperSlim does not return the first header when calling getChildAt(0), but the first (non-header) item in the first section.

How can I get the first header? I need it's height of other calculations.

Checking out the source code I found the function "getHeaderOrFirstViewForSection" which seems to be what I am lookin for, however it is declared private so I cannot access it.

user1354603
  • 4,034
  • 4
  • 31
  • 43
  • Where do you call this getChildAt(0) from? can you post some code? – ThanosFisherman Jun 21 '15 at 23:49
  • We tried to call getChildAt(0) on both the recyclerView and layoutmanager. However this is not an issue anymore as we were able to get the header with the following call : getLayoutManager().findViewByPosition(0) – user1354603 Jun 22 '15 at 11:23
  • SuperSLiM keeps header views attached after section views to ensure they are drawn after the section content. As you've discovered, with recyclerView you shouldn't make assumptions about the ordering of children and just use findViewByPosition instead. – Tonic Artos Jun 26 '15 at 13:25

1 Answers1

0

I solved this problem by this article https://github.com/2013mzhou/blog/blob/master/bug%26extend/Get%20StickyHeaderView%20in%20SuperSLiM.md .It's run well.

when useing like this

   final LayoutManager layout = new LayoutManager(getActivity());
    layout.setOnHeaderListener(new LayoutManager.StickyHeaderWatcher() {
        @Override
        public void onStickyStateChanged(View header, int position) {
            Log.i("StickyHeaderWatcher",position+"");
            if (header instanceof TextView) {
                Log.i("StickyHeaderWatcher", ((TextView) header).getText().toString());
            }
        }
    });
Mzhou
  • 1
  • 2