public abstract class BaseAdapters extends RecyclerView.Adapter<BaseAdapters.MyViewHolder> implements View.OnClickListener {
protected Context parentContext;
public int layout_id;
protected List<?> dataList = new ArrayList<>();
public class MyViewHolder extends RecyclerView.ViewHolder {
MyViewHolder(View view) {
super(view);
declareViews(view,this);
}
}
@Override
public void onClick(View view) {
onClickViews(view);
}
@Override
public int getItemViewType(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int i) {
bindView(holder, i);
}
public void notifyList(List<?> filterdNames) {
this.dataList = filterdNames;
notifyDataSetChanged();
}
@Override
public int getItemCount() {
if (dataList.size() == 0)
return 5;
else
return dataList.size();
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(layout_id, parent, false);
return new MyViewHolder(itemView);
}
public abstract MyViewHolder bindView(MyViewHolder holder, int position);
public abstract void onClickViews(View view);
public abstract void declareViews(View view,MyViewHolder holder);
}
How can i perform on click of every item selection using holder in child class extending with it.
every item selection
mean on full row or some item component click? – AutolysisbindView
method in child class, is there any issue? – Autolysis