0

My expect

As you saw picture above, i want to binding data same design and data like the picture. I used recycle view to do that. I tried to use girdlayoutmanager to separate row 1 to 2 columns, but i cant not. Then i custom a layout like row 1, but with each data in list it will generate a viewholder.

Can anyone suggest me some solutions for this problem. Thank so much!

Lão Tà
  • 78
  • 1
  • 9
  • You should be able to do this with getItemViewType(). You will need create two different view holder classes. You can see how to do it here: https://stackoverflow.com/a/26245463/5124783 – Hoang Nguyen Mar 17 '18 at 06:38

1 Answers1

0

When you bind data into Adapter that time given list in that onBindViewHolder() method call get value from the list then make if condition and hide view according to the value like below example:

@Override
public void onBindViewHolder(ItemViewHolder holder, int position) {
    User user=mUserLsit.get(position);
    if(user.getData()==Data1){
        holder.mTvPwd.setVisibility(View.GONE); 
    }
}

then when you need that view that time visiable the view.

Garg
  • 2,731
  • 2
  • 36
  • 47
  • So how you solve to bind Data1, Data2, Data 3 to one viewholder? – Lão Tà Mar 17 '18 at 05:31
  • make pojo class for all data then after on bind get the pojo data and check data value and bind data into view according view. –  Mar 17 '18 at 06:56