title: How to implement an ArrayList of Objects as views in a RecyclerView ViewHolder?
body: <p>I'm trying to populate a RecyclerView with unique views (Buttons, TextViews, Views, etc) via an ArrayList of ArrayLists of Objects. Just know that the first Object element is actually the id of a view.</p>
  
  <p>The problem is I'm not sure how to call the particular view using the ViewHolder object in the onBindViewHolder method since all the views are initialized in the ArrayList. So this is what I've tried, but this line
  <code>detailsViewHolder.((TextView) viewTypes.get(i)).setText("A Text");</code> is not even syntactically correct.</p>
  
  <pre><code>private class DetailsAdapter extends RecyclerView.Adapter&lt;DetailsAdapter.DetailsViewHolder&gt; {
  
      private ArrayList&lt;ArrayList&lt;Object&gt;&gt; viewBundle;
  
      public DetailsAdapter(ArrayList&lt;ArrayList&lt;Object&gt;&gt; viewBundle){
          this.viewBundle = viewBundle;
          viewTypes = new ArrayList&lt;&gt;();
      }
  
      public class DetailsViewHolder extends RecyclerView.ViewHolder{
  
          private ArrayList&lt;View&gt; viewTypes;
  
          public DetailsViewHolder(View itemView){
              super(itemView);
              viewTypes = new ArrayList&lt;&gt;();
              for (int i = 0; i &lt; viewBundle.size(); i++) {
                  viewTypes.add(itemView.findViewById((Integer) viewBundle.get(i).get(0)));
              }
          }
      }
  
      @Override
      public int getItemCount() {
          return viewBundle.size();
      }
  
      @NonNull
      @Override
      public DetailsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int i) {
          View resItemView = LayoutInflater.from(parent.getContext()).inflate((Integer) viewBundle.get(i).get(1), parent, false);
          DetailsViewHolder viewHolder = new DetailsViewHolder(resItemView);
          return viewHolder;
      }
  
      @Override
      public void onBindViewHolder(@NonNull DetailsViewHolder detailsViewHolder, int i) {
          detailsViewHolder.((TextView) viewTypes.get(i)).setText("A Text");
      }
  
  
  }
  </code></pre>