title: How to create a recylerview inside a recylerview item?
body: <p>I'm creating a NotesApp and I have a recylerview which is shown in my Activity called NotesActivity, when I click on a recylerview item it opens up another Activity called Classwork (which have another recyclerview in it). The idea is to create assignment lists inside each note (recyclerview item)</p>
  <p>The problem is when I create an assignment it is shown in the NotesActivity instead of ClassworkActivity. I created an Adapter and a Listdata for each of those 2 recylerviews</p>
  <p>This is what I tried:</p>
  <p><strong>NotesAdapter.java</strong></p>
  <pre><code>public class NotesAdapter extends RecyclerView.Adapter&lt;NotesAdapter.MyHolder&gt; {
  
      List&lt;Listdata&gt; noteslist;
      private Context context;
      public  NotesAdapter(List&lt;Listdata&gt; noteslist,Context context) {
          this.context=context;
          this.noteslist=noteslist;
      }
  
  
      @NonNull
      @Override
      public MyHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
          View view= LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item,viewGroup,false);
  
          MyHolder myHolder=new MyHolder(view);
          return myHolder;
  
      }
  
      @Override
      public void onBindViewHolder(@NonNull final MyHolder myHolder, final int position) {
          final Listdata data=noteslist.get(position);
          myHolder.title.setText(data.getTitle());
          myHolder.desc.setText(data.getDesc());
          myHolder.menuIcon.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
  
                  PopupMenu popupMenu = new PopupMenu(context, myHolder.menuIcon);
                  popupMenu.inflate(R.menu.popup_menu);
                  popupMenu.setGravity(Gravity.END);
                  popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                      @Override
                      public boolean onMenuItemClick(MenuItem item) {
  
                          switch (item.getItemId()) {
                              case R.id.action_edit:
                                  Toast.makeText(context, &quot;Edit&quot;, Toast.LENGTH_SHORT).show();
                                  Intent i=new Intent(context, EditActivity.class);
                                  i.putExtra(&quot;id&quot;,data.id);
                                  i.putExtra(&quot;title&quot;,data.title);
                                  i.putExtra(&quot;desc&quot;,data.desc);
                                  context.startActivity(i);
                                  break;
                              case R.id.action_delete:
                                  noteslist.remove(position);
                                  notifyDataSetChanged();
                                  Toast.makeText(context, &quot;delete&quot;, Toast.LENGTH_SHORT).show();
                                  break;
                              default:
                                  break;
                          }
  
                          return false;
                      }
                  });
                  popupMenu.show();
              }
          });
  
  
  
      }
  
      @Override
      public int getItemCount() {
          return noteslist.size();
      }
  
  
      class  MyHolder extends RecyclerView.ViewHolder  {
          TextView title,desc;
          ImageView menuIcon;
  
          public MyHolder(@NonNull View itemView) {
              super(itemView);
              menuIcon = itemView.findViewById(R.id.menuIcon);
              title=itemView.findViewById(R.id.title);
              desc=itemView.findViewById(R.id.desc);
              itemView.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      Listdata listdata=noteslist.get(getAdapterPosition());
                      Intent i=new Intent(context, StreamActivity.class);
                      i.putExtra(&quot;id&quot;,listdata.id);
                      i.putExtra(&quot;title&quot;,listdata.title);
                      i.putExtra(&quot;desc&quot;,listdata.desc);
                      context.startActivity(i);
                  }
              });
  
  
          }
  
      }
  
  }
  </code></pre>
  <p><strong>AssignmentAdapter.java</strong></p>
  <pre><code>public class AssignmentAdapter extends RecyclerView.Adapter&lt;AssignmentAdapter.MyHolder&gt;  {
  
      private List&lt;AssignListdata&gt; assignmentlist;
      private Context context;
      public  AssignmentAdapter(List&lt;AssignListdata&gt; assignmentlist, Context context) {
          this.context=context;
          this.assignmentlist=assignmentlist;
      }
  
      @NonNull
      @Override
      public AssignmentAdapter.MyHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
          View view= LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.assignment_item,viewGroup,false);
  
          AssignmentAdapter.MyHolder myHolder=new AssignmentAdapter.MyHolder(view);
          return myHolder;
      }
  
      @Override
      public void onBindViewHolder(@NonNull final AssignmentAdapter.MyHolder myHolder, final int position) {
  
  
          final AssignListdata data=assignmentlist.get(position);
          myHolder.titleas.setText(data.getTitle());
          myHolder.descas.setText(data.getDesc());
  
  
  
  
      }
  
      @Override
      public int getItemCount() {
          return assignmentlist.size();
      }
  
  
      class  MyHolder extends RecyclerView.ViewHolder  {
          TextView titleas,descas;
          ImageView menuIcon;
  
          public MyHolder(@NonNull View itemView) {
              super(itemView);
              titleas=itemView.findViewById(R.id.title_as);
              descas=itemView.findViewById(R.id.desc_as);
              itemView.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      AssignListdata listdata=assignmentlist.get(getAdapterPosition());
                      Intent i=new Intent(context, EditAssignActivity.class);
                      i.putExtra(&quot;id&quot;,listdata.id);
                      i.putExtra(&quot;title&quot;,listdata.titleas);
                      i.putExtra(&quot;desc&quot;,listdata.descas);
                      context.startActivity(i);
                  }
              });
  
  
          }
  
      }
  }
  </code></pre>
  <p><strong>AssignListdata.java</strong> (for the Assignment List which supposed to be created inside each note)</p>
  <pre><code>public class AssignListdata {
  
      public String getTitle() {
          return titleas;
      }
  
      public void setTitle(String title) {
          this.titleas = title;
      }
  
      public String getDesc() {
          return descas;
      }
  
      public void setDesc(String desc) {
          this.descas = desc;
      }
      public String getId() {
          return id;
      }
  
      public void setId(String id) {
          this.id = id;
      }
      public String id;
      public String titleas;
      public String descas;
  
      public AssignListdata() {
          // Default constructor required for calls to DataSnapshot.getValue(User.class)
      }
  
      public AssignListdata(String id,String title, String desc) {
          this.id=id;
          this.titleas = title;
          this.descas = desc;
  
      }
  }
  </code></pre>
  <p><strong>Listdata.java</strong> (for the Notes)</p>
  <pre><code>public class Listdata {
  
      public String getTitle() {
          return title;
      }
  
      public void setTitle(String title) {
          this.title = title;
      }
  
      public String getDesc() {
          return desc;
      }
  
      public void setDesc(String desc) {
          this.desc = desc;
      }
      public String getId() {
          return id;
      }
  
      public void setId(String id) {
          this.id = id;
      }
      public String id;
      public String title;
      public String desc;
  
      public Listdata() {
          // Default constructor required for calls to DataSnapshot.getValue(User.class)
      }
  
      public Listdata(String id,String title, String desc) {
          this.id=id;
          this.title = title;
          this.desc = desc;
  
      }
  
  }
  </code></pre>
  <p>and you can find in this link, my other files (especially the Add and Edit activities): <a href="https://github.com/XLogger-g/Recyclerview-test" rel="nofollow noreferrer">my Add and Edit activities</a></p>