title: Filling the Child items when expanding the parent of recycler view
body: <p>In my project I have to use the Expandable feature in listview or a recyclerview. I selected the recyclerview as It is better in performance. </p>
  
  <p>But I have to make the Expandable version So I got very nice library over <a href="https://github.com/bignerdranch/expandable-recycler-view" rel="nofollow">here</a> 
  and it really works good. But then I have a problem and that is as under </p>
  
  <ul>
  <li>I want to fill the Child views info from web service which should be called when user will click on the parent item. I have no Idea How it could be done using the same library </li>
  <li>I want to make the never ending RecyclerView so its mean I have to use some thing like pull to refresh type of thing but that will happen when user will arrive to the end of RecyclerView. Any idea how I can I implement these two functionalities using the same library ? </li>
  </ul>
  
  <p>Please help me and show me the right way of doing this . At least for the first confusion . Thanks in advance </p>
  
  <p><strong>Update 1:</strong> </p>
  
  <p>The Source Code I am sharing below is the code from the demo of this library 
  In this code snippt you can see he is setting child list (Item List)while creating the object of the ParentList (group list).  Where as I want to fill child list after fetching from the webservice </p>
  
  <pre><code>public class Recipe implements ParentListItem {
  
  private String mName;
  private List&lt;Ingredient&gt; mIngredients;
  
  public Recipe(String name, List&lt;Ingredient&gt; ingredients) {
      mName = name;
      mIngredients = ingredients;
  }
  
  public String getName() {
      return mName;
  }
  
  @Override
  public List&lt;?&gt; getChildItemList() {
      return mIngredients; // How can I return list after getting data from the web service 
  }
  
  @Override
  public boolean isInitiallyExpanded() {
      return false;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and he set it as </p>
  
  <pre><code>    @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_recycler_view_sample);
  
      Ingredient beef = new Ingredient("beef");
      Ingredient cheese = new Ingredient("cheese");
      Ingredient salsa = new Ingredient("salsa");
      Ingredient tortilla = new Ingredient("tortilla");
      Ingredient ketchup = new Ingredient("ketchup");
      Ingredient bun = new Ingredient("bun");
  
      Recipe taco = new Recipe("taco", Arrays.asList(beef, cheese, salsa, tortilla));
      Recipe quesadilla = new Recipe("quesadilla", Arrays.asList(cheese, tortilla));
      Recipe burger = new Recipe("burger", Arrays.asList(beef, cheese, ketchup, bun));
      final List&lt;Recipe&gt; recipes = Arrays.asList(taco, quesadilla, burger);
  
      RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
      mAdapter = new RecipeAdapter(this, recipes);
      mAdapter.setExpandCollapseListener(new ExpandableRecyclerAdapter.ExpandCollapseListener() {
          @Override
          public void onListItemExpanded(int position) {
              Recipe expandedRecipe = recipes.get(position);
  
              String toastMsg = getResources().getString(R.string.expanded, expandedRecipe.getName());
              Toast.makeText(VerticalLinearRecyclerViewSampleActivity.this,
                      toastMsg,
                      Toast.LENGTH_SHORT)
                      .show();
          }
  
          @Override
          public void onListItemCollapsed(int position) {
              Recipe collapsedRecipe = recipes.get(position);
  
              String toastMsg = getResources().getString(R.string.collapsed, collapsedRecipe.getName());
              Toast.makeText(VerticalLinearRecyclerViewSampleActivity.this,
                      toastMsg,
                      Toast.LENGTH_SHORT)
                      .show();
          }
      });
  
      recyclerView.setAdapter(mAdapter);
      recyclerView.setLayoutManager(new LinearLayoutManager(this));
  </code></pre>
  
  <p><strong>error Log</strong>  This error occur when i try to populate ingredient list from webservice. What I did I made the ingredient list static and from webservice I set it statically and retrieve it from the override function </p>
  
  <blockquote>
    <p>Process: com.naziraschool.nazraschoolsystem, PID: 484
                                                                                    java.lang.IndexOutOfBoundsException: Invalid index 4, size is 4
                                                                                        at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
                                                                                        at java.util.ArrayList.remove(ArrayList.java:403)
                                                                                        at com.bignerdranch.expandablerecyclerview.Adapter.ExpandableRecyclerAdapter.collapseParentListItem(ExpandableRecyclerAdapter.java:604)
                                                                                        at com.bignerdranch.expandablerecyclerview.Adapter.ExpandableRecyclerAdapter.onParentListItemCollapsed(ExpandableRecyclerAdapter.java:274)
                                                                                        at com.bignerdranch.expandablerecyclerview.ViewHolder.ParentViewHolder.collapseView(ParentViewHolder.java:164)
                                                                                        at com.bignerdranch.expandablerecyclerview.ViewHolder.ParentViewHolder.onClick(ParentViewHolder.java:124)</p>
  </blockquote>