I'm beginner in programming, I have so many classes like "AddItemBinding" (each of them, is matched to own xml layout).
public class MainViewHolder extends RecyclerView.ViewHolder{
private AddItemBinding binding;
public MainViewHolder(@NonNull View itemView) {
super(itemView);
binding = DataBindingUtil.bind(itemView);
}
public void bindItemsModel(ViewModel viewModel) {
binding.setModel(viewModels.get(getPosition()).viewDataSet);
}
}
how to instantiate each class from its name stored in a String? like this:
private viewModels.get(getPosition).className binding;
className is a String field contains name of a class.
Context: I have designed a recyclerView. Each item of the recyclerView has its own layout. A data set list, passed to Adapter. these data includes the layouts addresses. I want to do this: in the Adapter class, for each item, reads layout address and corresponding binding class. name of the binding class, saved as a String.