title: how receive arraylist in fragment
body: <p>I need to know how to get array list using Bundle in fragment , in the <a href="https://stackoverflow.com/questions/9245408/best-practice-for-instantiating-a-new-android-fragment">examples</a> I have seen they are using ints or strings. how to get fragments ? In my activity it was working good getting the arraylist </p>
  
  <p>my updated code</p>
  
  <pre><code>public class SingleViewActivity extends FragmentActivity {
      ImageView   imageView;
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_page_view);
  
  
          ArrayList&lt;Listitem&gt; personArrayList = new ArrayList&lt;Listitem&gt;();
  // add some ListItem's...
          DemoObjectFragment f = DemoObjectFragment.newInstance(personArrayList);
  
  
          ViewPager    mViewPager = (ViewPager) findViewById(R.id.pager);
          imageView = (ImageView) findViewById(R.id.funnyimage);
          Bundle bundle = getIntent().getExtras();
          Log.d("s","singleview");
          mViewPager.setAdapter(mDemoCollectionPagerAdapter);
  
  
  /*
          DemoCollectionPagerAdapter      mDemoCollectionPagerAdapter =      new DemoCollectionPagerAdapter( getSupportFragmentManager());
          ViewPager    mViewPager = (ViewPager) findViewById(R.id.pager);
             imageView = (ImageView) findViewById(R.id.funnyimage);
          Bundle bundle = getIntent().getExtras();
          Log.d("s","singleview");
          mViewPager.setAdapter(mDemoCollectionPagerAdapter);*/
  
      /*  if (savedInstanceState == null) {
              // During initial setup, plug in the details fragment.
              MyFragment myrag = new MyFragment();
              myrag.setArguments(getIntent().getExtras());
              getSupportFragmentManager().beginTransaction().add(android.R.id.content, myrag).commit();
          }
  */
      }
  </code></pre>
  
  <hr>
  
  <pre><code>        // Since this is an object collection, use a FragmentStatePagerAdapter,
          // and NOT a FragmentPagerAdapter.
  
          public class DemoCollectionPagerAdapter extends FragmentStatePagerAdapter {
              public static final String ARG_OBJECT = "Person_List";
  
              public DemoCollectionPagerAdapter(FragmentManager fm, ArrayList&lt;Listitem&gt; personArrayList)
              {
                  super(fm);
                  Log.d("s","adapterview");
              }
  
              @Override
              public Fragment getItem(int i) {
  
                  Fragment fragment = new DemoObjectFragment();
                  Bundle args = new Bundle();
                  // Our object is just an integer :-P
                  args.putInt(DemoObjectFragment.ARG_PERSON_LIST, i + 1);
                  fragment.setArguments(args);
                  return fragment;
              }
  
              @Override
              public int getCount() {
                  return 100;
              }
  
              @Override
              public CharSequence getPageTitle(int position) {
                  return "OBJECT " + (position + 1);
              }
          }
  </code></pre>
  
  <hr>
  
  <pre><code>// Instances of this class are fragments representing a single
  // object in our collection.
  public class DemoObjectFragment extends Fragment {
      public static final String ARG_PERSON_LIST = "Person_List";
  
      private ArrayList&lt;Listitem&gt; items;
  
      public  DemoObjectFragment newInstance(ArrayList&lt;Listitem&gt; items) {
          DemoObjectFragment f = new DemoObjectFragment();
          Bundle args = new Bundle();
          args.putParcelableArrayList(ARG_PERSON_LIST, items);
          f.setArguments(args);
          return f;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          Bundle args = getArguments();
          if (args.containsKey(ARG_PERSON_LIST)) {
              // UNTESTED: probably will need to cast this
              this.items = args.getParcelableArrayList(ARG_PERSON_LIST);
          } else { // avoid the NullPointerException later by initializing the list
              this.items = new ArrayList&lt;Listitem&gt;();
          }
          // use this.items as you wish, but it will be empty if you didn't set the Bundle argument correctly
      }
  }
              @Override
              public View onCreateView(LayoutInflater inflater,
                                       ViewGroup container, Bundle savedInstanceState) {
                  // The last two arguments ensure LayoutParams are inflated
                  // properly.
  
                  View rootView = inflater.inflate(
                          R.layout.fragment_collection_object, container, false);
                //  Bundle args = getArguments();
               //   ((TextView) rootView.findViewById(R.id.text1)).setText(Integer.toString(args.getInt(ARG_OBJECT)));
                  Bundle args= new Bundle();
  
  
  
                  ArrayList&lt;Listitem&gt; personArrayList = args.getParcelableArrayList("Person_List");
                  System.out.print(personArrayList);
  
                  System.out.print("here1");
  
                  if (personArrayList != null &amp;&amp; !personArrayList.isEmpty()) {
                      for (Listitem person : personArrayList) {
                          Picasso.
                                  with(getActivity()).
                                  load(person.url)
                                  .placeholder(R.drawable.logo)
                                  .fit()
                                  .noFade()
                                  .into(imageView);
                          Log.i("PersonsActivity",String.valueOf(person.url));
                      }
                  }
                  return rootView;
              }
          }
      }
  </code></pre>
  
  <hr>
  
  <p>I have 2 errors now :
  <a href="https://i.stack.imgur.com/oq030.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oq030.png" alt="enter image description here"></a></p>
  
  <p>for newInstance as I mentioned before I cannot refer to not static .</p>
  
  <p>and I am getting error now for picasso </p>
  
  <p><a href="https://i.stack.imgur.com/qs014.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qs014.png" alt="enter image description here"></a></p>
  
  <p>edit 3 <a href="https://i.stack.imgur.com/szAhT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/szAhT.png" alt="enter image description here"></a></p>