title: Dynamically load items to ExpandableListView using ExpandableListAdapter
body: <p>This is my Activity I used to display my items in Expandable List View. At the moment I have hard coded the values which should come to the Expandable List View.</p>
  
  <pre><code>String subTotal = getIntent().getStringExtra("subTotal"); // I have these 2 values
  String price = getIntent().getStringExtra("price");
  </code></pre>
  
  <p>These are the 2 values I wanna load dynamically.</p>
  
  <p>In the below I have <code>prepareListData()</code>, where I have hard coded values to my ExpandableListView. </p>
  
  <pre><code>listDataHeader.add("Top 250"); // subTotal
  List&lt;String&gt; top250 = new ArrayList&lt;String&gt;();
  top250.add("The Shawshank"); //price
  </code></pre>
  
  <p>I want to know how to replace these hard coded values with my dynamic values. Any help would be highly appreciated.</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.cart_activity);
  
      String subTotal = getIntent().getStringExtra("subTotal"); // i ahve these 2 values
      String price = getIntent().getStringExtra("price");//
  
      ActionBar actionBar = getActionBar();
      getActionBar().setIcon(
              new ColorDrawable(getResources().getColor(android.R.color.transparent)));
      getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
      // Enabling Back navigation on Action Bar icon
      actionBar.setDisplayHomeAsUpEnabled(true);
  
      // get the listview
              expListView = (ExpandableListView) findViewById(R.id.lvExp);
  
              // preparing list data
              prepareListData();
  
              listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild);
  
              // setting list adapter
              expListView.setAdapter(listAdapter);
  
              // Listview Group click listener
              expListView.setOnGroupClickListener(new OnGroupClickListener() {
  
                  @Override
                  public boolean onGroupClick(ExpandableListView parent, View v,
                          int groupPosition, long id) {
                       Toast.makeText(getApplicationContext(),
                       "Group Clicked " + listDataHeader.get(groupPosition),
                       Toast.LENGTH_SHORT).show();
                      return false;
                  }
              });
  
              // Listview Group expanded listener
              expListView.setOnGroupExpandListener(new OnGroupExpandListener() {
  
                  @Override
                  public void onGroupExpand(int groupPosition) {
                      Toast.makeText(getApplicationContext(),
                              listDataHeader.get(groupPosition) + " Expanded",
                              Toast.LENGTH_SHORT).show();
                  }
              });
  
              // Listview Group collasped listener
              expListView.setOnGroupCollapseListener(new OnGroupCollapseListener() {
  
                  @Override
                  public void onGroupCollapse(int groupPosition) {
                      Toast.makeText(getApplicationContext(),
                              listDataHeader.get(groupPosition) + " Collapsed",
                              Toast.LENGTH_SHORT).show();
  
                  }
              });
  
              // Listview on child click listener
              expListView.setOnChildClickListener(new OnChildClickListener() {
  
                  @Override
                  public boolean onChildClick(ExpandableListView parent, View v,
                          int groupPosition, int childPosition, long id) {
                      // TODO Auto-generated method stub
                      Toast.makeText(
                              getApplicationContext(),
                              listDataHeader.get(groupPosition)
                                      + " : "
                                      + listDataChild.get(
                                              listDataHeader.get(groupPosition)).get(
                                              childPosition), Toast.LENGTH_SHORT)
                              .show();
                      return false;
                  }
              });
          }
  
          /*
           * Preparing the list data
           */
          private void prepareListData() {
              listDataHeader = new ArrayList&lt;String&gt;();
              listDataChild = new HashMap&lt;String, List&lt;String&gt;&gt;();
  
              // Adding child data
              listDataHeader.add("Top 250"); // subTotal
  
              // Adding child data
              List&lt;String&gt; top250 = new ArrayList&lt;String&gt;();
              top250.add("The Shawshank"); //price
  
              listDataChild.put(listDataHeader.get(0), top250); // Header, Child data
  
              DisplayMetrics metrics = new DisplayMetrics();
              getWindowManager().getDefaultDisplay().getMetrics(metrics);
              int width = metrics.widthPixels; 
  
           mExpandableList = (ExpandableListView)findViewById(R.id.lvExp);
           mExpandableList.setIndicatorBounds(width - GetPixelFromDips(50), width - GetPixelFromDips(10));  }
  
             public int GetPixelFromDips(float pixels) {
              // Get the screen's density scale 
              final float scale = getResources().getDisplayMetrics().density;
              // Convert the dps to pixels, based on density scale
              return (int) (pixels * scale + 0.5f);
  
          }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/ktE7w.png" alt="enter image description here"></p>