jaychang0917 / SimpleRecyclerView

A RecyclerView extension for building list more easily.
Apache License 2.0
935 stars 104 forks source link

How to add one main header for Section Header ? #6

Closed peddiraju211 closed 7 years ago

jaychang0917 commented 7 years ago

Hi @peddiraju211 what do you means?

peddiraju211 commented 7 years ago

@jaychang0917 Sorry for incomplete question

Can we add header view for RecyclerView at Section Header functionality ? From below screenshot I have used fixed header view. But I want to add that header view along with RecyclerView items. Any suggestions? screenshot_1486991776

jaychang0917 commented 7 years ago

What's your fixed header view mean? Sticky? Can you describe what effect you want?

peddiraju211 commented 7 years ago

The RecyclerView first item must be a header view/inflate a view and when we scroll RecyclerView the header view also scroll along with RecyclerView items.

jaychang0917 commented 7 years ago

New release 1.1.2 supports multiple cell type for section header now. Pls check it out.

jaychang0917 commented 7 years ago

If you have any further questions, please feel free to reopen this issue, thanks!

peddiraju211 commented 7 years ago

Could you please explain more about how to add that "Header" using multiple cell type ?

I have tried with below code but not working well

   @Override
        public View getSectionHeaderView(PersionData item, int position) {
            if(position==0){
                View view = LayoutInflater.from(getActivity()).inflate(R.layout.header_item, null, false);
                TextView textView = (TextView) view.findViewById(R.id.txtHeader);
                textView.setText("Header");
                return view;
            }else{
                View view = LayoutInflater.from(getActivity()).inflate(R.layout.view_section_header, null, false);
                TextView textView = (TextView) view.findViewById(R.id.textView);
                textView.setText(String.format(getString(R.string.branchInformation), item.getCategoryName()));
                return view;
            }

        }
jaychang0917 commented 7 years ago

You can refer to multi_types.

jaychang0917 commented 7 years ago

Your getSectionHeaderView() method should return your section view only, and create a new header cell, then call recyclerview.addCell(0, headerCell).