update
This commit is contained in:
@@ -14,14 +14,17 @@ import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.bean.GiftBean;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GiftListAdapter extends RecyclerView.Adapter<GiftListAdapter.ViewHolder> {
|
||||
private Context mContext;
|
||||
private List<GiftBean> list;
|
||||
private int selectPosition = 0;
|
||||
|
||||
public GiftListAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void setList(List<GiftBean> list) {
|
||||
@@ -45,7 +48,7 @@ public class GiftListAdapter extends RecyclerView.Adapter<GiftListAdapter.ViewHo
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private ImageView giftIcon;
|
||||
private TextView giftName;
|
||||
private TextView money;
|
||||
@@ -56,9 +59,10 @@ public class GiftListAdapter extends RecyclerView.Adapter<GiftListAdapter.ViewHo
|
||||
giftIcon = itemView.findViewById(R.id.gift_icon);
|
||||
giftName = itemView.findViewById(R.id.gift_name);
|
||||
money = itemView.findViewById(R.id.money);
|
||||
select.findViewById(R.id.bg_select);
|
||||
select = itemView.findViewById(R.id.bg_select);
|
||||
itemView.setOnClickListener(v -> {
|
||||
select.setVisibility(View.VISIBLE);
|
||||
selectPosition = getAbsoluteAdapterPosition();
|
||||
notifyDataSetChanged();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -67,6 +71,12 @@ public class GiftListAdapter extends RecyclerView.Adapter<GiftListAdapter.ViewHo
|
||||
money.setText(giftBean.getNeedcoin() + "");
|
||||
ImgLoader.display(itemView.getContext(), giftBean.getGifticon(), giftIcon);
|
||||
select.setVisibility(View.GONE);
|
||||
|
||||
if (position == selectPosition) {
|
||||
select.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
select.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user