
So if a phone is blank then RecyclerView shows email UI and if an email is blank then RecyclerView shows call UI. So if we keep phone blank that means value for email is mandatory and same vice-versa if we keep email blank that means a value of a phone is mandatory. In that class, we have two fields, phone and email. We use the same model class for both view holders. So let’s create two layouts for two different items in recyclerview: item_call.xml and item_email.xml One for call layout and another one for email layout. Now here we will create a RecyclerView with two different views.

For that, here we will make multiple view holder for the single RecyclerView. We have just change RecyclerView adapter to make it compatible with multiple views. Here it is an example of Android RecyclerView with multiple views.
