Monday 8 August 2016

Shopping Navigation List with Three Level Expandable Recycler View

SwiftAdapter is an easy to use expandable list recyclerview adapter



Import Using Gradle

compile 'com.vkondrav.swiftadapter:swift-adapter:0.2.0'

Quickstart

Extend the SwiftAdapter
private static class Adapter extends SwiftAdapter<Adapter.ViewHolder> {
Declare you main ViewHolder
public class ViewHolder extends RecyclerView.ViewHolder {
  public ViewHolder(View itemView) {
    super(itemView);
  }
}
Override count method to declare how many items of that type you will have
@Override
public int getNumberOfLvl0Items() {
  return 10;
}
Override onCreate method to create a specific type of item
@Override
public ViewHolder onCreateLvl0ItemViewHolder(ViewGroup parent) {
  return new ViewHolder(layoutInflater.inflate(R.layout.lvl0_item_layout, parent, false));
}
Override to bind data to the viewholder
@Override
public void onBindLvl0Item(ViewHolder holder, ItemIndex index) {
}

Advanced

There are 4 Levels where the view holders can exist. Each section hosts the items and sections below it.
  • Level 0 Items
  • Level 1 Sections
    • Level 1 Items
    • Level 2 Sections
      • Level 2 Items
      • Level 3 Sections
        • Level 3 Items
Each layer has a set of methods to construct it. By overriding these methods you can create each layer of the list
int getNumberOf_()
ViewHolder CreateViewHolder_()
void BindViewHolder_(ViewHolder holder, ItemIndex)
Open and Close each section by calling these methods and passing ItemIndex from that section.
void openCloseLvl1Section(ItemIndex itemIndex);
void openCloseLvl2Section(ItemIndex itemIndex);
void openCloseLvl3Section(ItemIndex itemIndex);
ItemIndex can always be obtained from the specific OnBind Method or by calling getCurrentItemIndex and passing the ViewHolder for that section
public ItemIndex getCurrentItemIndex(T holder)
Need Source for Android Studio Project below link
https://github.com/vkondrav/SwiftAdapter
Thank You

No comments:

Post a Comment

Send Whatsapp Message via PHP Code

  How to Send and Receive Messages in WhatsApp using PHP In this tutorial you will see How to Send and Receive Messages in WhatsApp using PH...