title: How to Pass ArrayList from Activity to Fragment in Android
body: <p>I have a MainActivity and a fragment. What I want to do is pass array list from my main activity to my fragment. </p>
  
  <p>In my MainActivity my code looks like this:</p>
  
  <pre><code>private final List&lt;RestaurantParcelableModel&gt; restaurantList = new ArrayList&lt;&gt;();
  ...
  RestaurantsFragment restaurantsFragment = new RestaurantsFragment();
          Bundle args = new Bundle();
          args.putParcelableArrayList("restaurantList", (ArrayList&lt;? extends Parcelable&gt;) restaurantList);
          restaurantsFragment.setArguments(args);
  
          FragmentManager fragmentManager = getFragmentManager();
          android.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
          fragmentTransaction.replace(R.id.restaurants_list, restaurantsFragment);
          fragmentTransaction.addToBackStack(null);
          fragmentTransaction.commit();
  </code></pre>
  
  <p>Right now I am getting this error in fragmentTransaction.replace(R.id.restaurants_list, <strong><em>restaurantsFragment</em></strong>); - "<em>Wrong 2nd argument type. Found: 'com.test.restaurants.sliderfragments.RestaurantsFragment', required: 'android.app.Fragment'
  replace     (int,   android.app.Fragment)   in FragmentTransaction cannot be applied 
  to  (int,   com.test.restaurants.sliderfragments.RestaurantsFragment)</em>"</p>