-2

I am trying to develop a quiz app in which sometimes questions have and image in the question is it possible to design two different single element view of recyclerview (one with image and other without image) and bind it to recycler view according to need.

0

1 Answer 1

0

In your oncreate viewholder based on position inflate the view like below

 private Context context; private List<MenuListItem>menuListItemList; private int position; public MenuItemsAdapter(Context context, List<MenuListItem> menuListItemList, int position) { this.context = context; this.menuListItemList = menuListItemList; this.position = position; } @NonNull @Override public MenuItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view; if (position==0){ view = LayoutInflater.from(context).inflate(R.layout.first_row_grid_item,parent,false); } else { view = LayoutInflater.from(context).inflate(R.layout.menu_items,parent,false); } return new MenuItemViewHolder(view); } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.