{"id":13642853,"url":"https://github.com/IntruderShanky/Sectioned-RecyclerView","last_synced_at":"2025-04-20T21:31:42.138Z","repository":{"id":144171757,"uuid":"69920546","full_name":"IntruderShanky/Sectioned-RecyclerView","owner":"IntruderShanky","description":"Easy implementation of RecyclerView with headers and items","archived":false,"fork":false,"pushed_at":"2017-10-12T12:41:59.000Z","size":17737,"stargazers_count":104,"open_issues_count":10,"forks_count":26,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-09T14:39:25.366Z","etag":null,"topics":["recyclerview","sectioned-recycler-view"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IntruderShanky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-10-03T23:50:30.000Z","updated_at":"2024-01-22T21:53:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"e0393905-8281-4c8b-b62d-c95f6b70b1c8","html_url":"https://github.com/IntruderShanky/Sectioned-RecyclerView","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IntruderShanky%2FSectioned-RecyclerView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IntruderShanky%2FSectioned-RecyclerView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IntruderShanky%2FSectioned-RecyclerView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IntruderShanky%2FSectioned-RecyclerView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IntruderShanky","download_url":"https://codeload.github.com/IntruderShanky/Sectioned-RecyclerView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249965535,"owners_count":21352921,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["recyclerview","sectioned-recycler-view"],"created_at":"2024-08-02T01:01:37.262Z","updated_at":"2025-04-20T21:31:41.609Z","avatar_url":"https://github.com/IntruderShanky.png","language":"Java","funding_links":[],"categories":["RecyclerView"],"sub_categories":[],"readme":"# Sectioned-RecyclerView\nEasy implementation of RecyclerView with headers and items\n\n[![](https://jitpack.io/v/IntruderShanky/Sectioned-RecyclerView.svg)](https://jitpack.io/#IntruderShanky/Sectioned-RecyclerView)\n[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Sectioned%20RecyclerView-blue.svg?style=flat)](http://android-arsenal.com/details/1/4495)\n[![API](https://img.shields.io/badge/API-11%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=11)\n\n[Demo App - IS Library](https://play.google.com/store/apps/details?id=com.intrusoft.islibrarydemo)\n\n\u003ca href='https://play.google.com/store/apps/details?id=com.intrusoft.islibrarydemo\u0026utm_source=global_co\u0026utm_small=prtnr\u0026utm_content=Mar2515\u0026utm_campaign=PartBadge\u0026pcampaignid=MKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1'\u003e\u003cimg alt='Get it on Google Play' src='https://play.google.com/intl/en_us/badges/images/generic/en_badge_web_generic.png' width=\"193\" height=\"75\"/\u003e\u003c/a\u003e\n\n### Demo\n![gif](demo.gif)\n\n### Usage\n##### Step 1. Add the JitPack repository to your build file\n###### Add it in your root build.gradle at the end of repositories:\n```groovy\nallprojects {\n   repositories {\n\t...\n\tmaven { url \"https://jitpack.io\" }\n   }\n}\n```\n##### Step 2. Add the dependency\n```groovy\ndependencies {\n   compile 'com.github.IntruderShanky:Sectioned-RecyclerView:2.1.1'\n}\n```\n### Implementation\nThere are very easy and simple steps to implement.\n##### Step 1. Add RecyclerView in layout file:\n```xml\n\u003candroid.support.v7.widget.RecyclerView\n   android:id=\"@+id/recycler_view\"\n   android:layout_width=\"match_parent\"\n   android:layout_height=\"wrap_content\" /\u003e\n```\n##### Step 2. Create another layout file for Section Header:\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cLinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:paddingTop=\"26dp\"\n    android:paddingLeft=\"16dp\"\n    android:paddingRight=\"16dp\"\n    android:orientation=\"vertical\"\u003e\n\n    \u003cTextView\n        android:id=\"@+id/section\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"16sp\"\n        android:textSize=\"16sp\"\n        android:textStyle=\"bold\"/\u003e\n    \u003cView\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"1dp\"\n        android:layout_marginTop=\"5dp\"\n        android:background=\"#88424242\"/\u003e\n\u003c/LinearLayout\u003e\n```\n\n##### Step 3. Create another layout file for Section Child:\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cLinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:paddingLeft=\"8dp\"\n    android:orientation=\"vertical\"\u003e\n\n    \u003cTextView\n        android:id=\"@+id/child\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:textSize=\"16sp\"\n        android:text=\"mc sjcnscdj \"\n        android:padding=\"8dp\"\n        android:fontFamily=\"sans-serif-condensed\"/\u003e\n\n\u003c/LinearLayout\u003e\n```\n\n##### Step 4. Create a class for Section Child and named it. Here \"Child.java\"\n```java\npublic class Child {\n\n    String name;\n\n    public Child(String name) {\n        this.name = name;\n    }\n\n    public String getName() {\n        return name;\n    }\n}\n```\n\n##### Step 5. Create a class for Section Header and implement it with Section. Here \"Section.java\"\n```java\npublic class SectionHeader implements Section\u003cChild\u003e {\n\n    List\u003cChild\u003e childList;\n    String sectionText;\n\n    public SectionHeader(List\u003cChild\u003e childList, String sectionText) {\n        this.childList = childList;\n        this.sectionText = sectionText;\n    }\n\n    @Override\n    public List\u003cChild\u003e getChildItems() {\n        return childList;\n    }\n\n    public String getSectionText() {\n        return sectionText;\n    }\n}\n```\n\n##### Step 6. Create a two ViewHolder classes to hold the views of section and child.\n```java\npublic class SectionViewHolder extends RecyclerView.ViewHolder {\n\n    TextView name;\n    public SectionViewHolder(View itemView) {\n        super(itemView);\n         name = (TextView) itemView.findViewById(R.id.section);\n    }\n}\n```\n\n```java\npublic class ChildViewHolder extends RecyclerView.ViewHolder {\n\n    TextView name;\n    public ChildViewHolder(View itemView) {\n        super(itemView);\n        name = (TextView) itemView.findViewById(R.id.child);\n    }\n}\n```\n\n##### Step 7. Create a Adater for RecyclerView. Here \"AdapterSectionRecycler.java\"\n```java\npublic class AdapterSectionRecycler extends SectionRecyclerViewAdapter\u003cSectionHeader, Child, SectionViewHolder, ChildViewHolder\u003e {\n\n    Context context;\n\n    public AdapterSectionRecycler(Context context, List\u003cSectionHeader\u003e sectionItemList) {\n        super(context, sectionItemList);\n        this.context = context;\n    }\n\n    @Override\n    public SectionViewHolder onCreateSectionViewHolder(ViewGroup sectionViewGroup, int viewType) {\n        View view = LayoutInflater.from(context).inflate(R.layout.section_item, sectionViewGroup, false);\n        return new SectionViewHolder(view);\n    }\n\n    @Override\n    public ChildViewHolder onCreateChildViewHolder(ViewGroup childViewGroup, int viewType) {\n        View view = LayoutInflater.from(context).inflate(R.layout.item_layout, childViewGroup, false);\n        return new ChildViewHolder(view);\n    }\n\n    @Override\n    public void onBindSectionViewHolder(SectionViewHolder sectionViewHolder, int sectionPosition, SectionHeader section) {\n        sectionViewHolder.name.setText(section.sectionText);\n    }\n\n    @Override\n    public void onBindChildViewHolder(ChildViewHolder childViewHolder, int sectionPosition, int childPosition, Child child) {\n        childViewHolder.name.setText(child.getName());\n    }\n}\n```\n\n##### Step 8. Here complete code of your Activity Class, Here \"MainActivity.java\"\n```java\npublic class MainActivity extends AppCompatActivity {\n\n    RecyclerView recyclerView;\n    AdapterSectionRecycler adapterRecycler;\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n\n        //initialize RecyclerView\n        recyclerView = (RecyclerView) findViewById(R.id.recycler_view);\n\n        //setLayout Manager\n        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);\n        recyclerView.setLayoutManager(linearLayoutManager);\n        recyclerView.setHasFixedSize(true);\n\n        //Create a List of Child DataModel\n        List\u003cChild\u003e childList = new ArrayList\u003c\u003e();\n        childList.add(new Child(\"April\"));\n        childList.add(new Child(\"Austin\"));\n        childList.add(new Child(\"Alex\"));\n        childList.add(new Child(\"Aakash\"));\n\n        //Create a List of Section DataModel implements Section\n        List\u003cSectionHeader\u003e sections = new ArrayList\u003c\u003e();\n        sections.add(new SectionHeader(childList, \"A\"));\n\n        childList = new ArrayList\u003c\u003e();\n        childList.add(new Child(\"Bill Gates\"));\n        childList.add(new Child(\"Bob Proctor\"));\n        childList.add(new Child(\"Bryan Tracy\"));\n        sections.add(new SectionHeader(childList, \"B\"));\n\n        childList = new ArrayList\u003c\u003e();\n        childList.add(new Child(\"Intruder Shanky\"));\n        childList.add(new Child(\"Invincible Vinod\"));\n        sections.add(new SectionHeader(childList, \"I\"));\n\n        childList = new ArrayList\u003c\u003e();\n        childList.add(new Child(\"Jim Carry\"));\n        sections.add(new SectionHeader(childList, \"J\"));\n\n        childList = new ArrayList\u003c\u003e();\n        childList.add(new Child(\"Neil Patrick Harris\"));\n        sections.add(new SectionHeader(childList, \"N\"));\n\n        childList = new ArrayList\u003c\u003e();\n        childList.add(new Child(\"Orange\"));\n        childList.add(new Child(\"Olive\"));\n        sections.add(new SectionHeader(childList, \"O\"));\n\n        adapterRecycler = new AdapterSectionRecycler(this, sections);\n        recyclerView.setAdapter(adapterRecycler);\n    }\n}\n```\n\n\nData Change Methods\n---------\n```java\ninsertNewSection(Section)\ninsertNewSection(Section, int)\nremoveSection(int)\ninsertNewChild(Object, int)\ninsertNewChild(Object, int, int)\nremoveChild(int, int)\n\n/* To notify the adapter for data change \n * call notifyDataChanged(List) instead of \n * notiftDatasetChanged()\n */ \nnotifyDataChanged(List)\n```\n\nLicence\n--------\n\n```\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIntruderShanky%2FSectioned-RecyclerView","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIntruderShanky%2FSectioned-RecyclerView","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIntruderShanky%2FSectioned-RecyclerView/lists"}