Search code examples
androidandroid-recyclerviewandroid-adaptercardview

How to use multiple layout using one RecyclerView Adapter?


Hey guys I'm implementing two cards in an recyclerview and also created two view holder but didn't get the code for adapter help me guys.

public class ViewHolder1 extends RecyclerView.ViewHolder {

    private TextView Chatin;

    public ViewHolder1(View v) {
        super(v);
        Chatin = (TextView) v.findViewById(R.id.Chatin);
    }

    public TextView getChatin() {
        return Chatin;
    }

    public void setChatin(TextView chatin) {
        this.Chatin = chatin;
    }


}

Other view holder is same as it is.


Solution

  • Yes we can use multiple cardView. For reference see below link for Sample Adapter :-https://github.com/subbuboyapati/MovieMasti/blob/master/app/src/main/java/com/subbu/moviemasti/adapter/ReviewAdapter.java

    This answer also help you. Can I Use Only One RecyclerView For The Three Different CardView With Different Design?

    Have a look at this tutorial also, http://arjunu.com/2015/10/android-recyclerview-with-different-cardviews/ .