[Solved] Recycler view like instagram


In your adapter class

private static final int POSTER = 1; //for sliding item
private static final int CHILDGROUP = 2; //normal items

In getItemViewType()

@Override
public int getItemViewType(int position) {

    if (position == 0 )
        return POSTER;
    else
        return CHILDGROUP;

}

In onCreateViewHolder() check which item & inflate layout as per item

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

    if (viewType == POSTER) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.listrow_auto_viewpager, parent, false);
        return new PosterSliderHolder(view);
    } else {
        View view = LayoutInflater.from(mContext).inflate(R.layout.listrow_sub_category, parent, false);
        return new GroupViewHolder(view);
    }
}

In onBindViewHolder() check the item type & load the data

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

    if (holder.getItemViewType() == POSTER) {
    final PosterSliderHolder posterViewHolder = (PosterSliderHolder) holder;
    //your logic for sliding item (horizontal recyclerview )
    }
    else{
    final GroupViewHolder groupViewHolder = (GroupViewHolder) holder;
     //normal list item
    }
 } 

7

solved Recycler view like instagram