title: Passing an arraylist from an activity to a java class in Android
body: <p>I have an arraylist in MainActivity and I have a java class which is not an <strong>acitivity</strong>. How can i pass this arraylist to this class ? My arraylist:</p>
  
  <pre><code>public List&lt;String&gt;  types = new ArrayList&lt;String&gt;();
  </code></pre>
  
  <p>and i filled in MainAcitivity. then i have to use in a java class which is name ExpandableListAdapter. Here is part of the java class which i have to do change in it and i tried to create new activity object but it didn't work.</p>
  
  <pre><code>public class ExpandableListAdapter extends BaseExpandableListAdapter {
  
  
   public View getChildView(int groupPosition, final int childPosition,
          boolean isLastChild, View convertView, ViewGroup parent) {
  
       MainActivity m=new MainActivity();
  
      Integer[]  mIcons = {R.drawable.car_1,R.drawable.car_2,R.drawable.car_3,R.drawable.car_4,R.drawable.car_5,R.drawable.car_6,R.drawable.car_7,R.drawable.car_8,R.drawable.car_9,R.drawable.car_10}
  
      Integer[] mIcons_2 = new Integer [m.types.size()];
  
      for(int i=0; i&lt;m.types.size(); i++){
  
      mIcons_2[i]= mIcons[ Integer.parseInt(m.types.get(i))];
  
  
  
  }
  
  
  
      final String childText = (String) getChild(groupPosition, childPosition);
  
      if (convertView == null) {
          LayoutInflater infalInflater = (LayoutInflater) this._context
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          convertView = infalInflater.inflate(R.layout.drawer_list_item, null);
      }
  
      ImageView iconn =(ImageView)convertView.findViewById(R.id.thumbNail);
  
      iconn.setImageResource(mIcons_2[childPosition]);
  
  
    TextView txtListChild = (TextView) convertView
              .findViewById(R.id.textView);
  
      txtListChild.setTextColor(Color.BLUE);
  
    txtListChild.setText(childText);
      return convertView;
  }
  </code></pre>
  
  <p>I created a navigation drawer with an expandable listview also i try to put different icons on every item. This ExpandableListAdapter class is about that but my problem is about how can i pass the types ArrayList from the MainActivity to the ExpandableListAdapter java class?  I know that using intent works when pass the values one activity to other activity but i didn't know about passing one activity to a java class.</p>