سلام
مشکلی برام پیش اومده که ممنون میشم کمکم کنید
وقتی اسکرول میکنم تا ته و دوباره برمیگردم جای ایتما به هم میریزه !
اینم کدم
هیچ فرقی با ریسایکلرایی که هزار بار زدم نداره !
public class ChooseRolesAdapter extends RecyclerView.Adapter<ChooseRolesAdapter.ChooseRolesViewHolder> {
private List<Role> roles;
private OnPositiveRoleEvent onPositiveRoleEvent;
private OnNegativeRoleEvent onNegativeRoleEvent;
private boolean isPositive;
ChooseRolesAdapter(OnPositiveRoleEvent onPositiveRoleEvent, boolean isPositive) {
this.onPositiveRoleEvent = onPositiveRoleEvent;
this.isPositive = isPositive;
setHasStableIds(true);
}
ChooseRolesAdapter(OnNegativeRoleEvent onNegativeRoleEvent,boolean isPositive){
this.onNegativeRoleEvent = onNegativeRoleEvent;
this.isPositive = isPositive;
setHasStableIds(true);
}
void addRoles(List<Role> roles) {
this.roles = roles;
}
@NonNull
@Override
public ChooseRolesViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new ChooseRolesViewHolder(LayoutInflater.from(parent.getContext())
.inflate(R.layout.rv_item_choose_roles_role, parent, false));
}
@Override
public void onBindViewHolder(@NonNull ChooseRolesViewHolder holder, int position) {
holder.bindItem(roles.get(position));
}
@Override
public int getItemCount() {
return roles.size();
}
public class ChooseRolesViewHolder extends RecyclerView.ViewHolder {
private MaterialCheckBox cbIsRoleSelected;
private ImageView ivDescription;
public ChooseRolesViewHolder(@NonNull View itemView) {
super(itemView);
cbIsRoleSelected = itemView.findViewById(R.id.cb_rvItemChooseRoles_isRoleSelected);
ivDescription = itemView.findViewById(R.id.iv_rvItemChooseRoles_description);
}
public void bindItem(Role role) {
cbIsRoleSelected.setText(role.getRoleName());
}
}
}