title: error passing arguments from an activity to a fragment in android
body: <p>I have been having an issue passing an ArrayList from my activity to my fragment. I have tried several different methods of doing so, however, it appears that the code is not passing <code>SetContentView</code> as seen below, the onCreate method is instanciating the fragment, however executes nothing after <code>SetContentView</code>:</p>
  
  <pre><code>    @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_drawer);
  
          Log.i(TAG, "scooby snacks");
  
          mNavigationDrawerFragment = (NavigationDrawerFragment)
                  getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
          mTitle = getTitle();
  
          ArrayList&lt;String&gt; menuItems = new ArrayList&lt;String&gt;();
          menuItems.add("Test");
  
          Bundle input = new Bundle();
          input.putStringArrayList("edttext", menuItems);
          /* set Fragmentclass Arguments */
          mNavigationDrawerFragment.setArguments(input);
          Log.i(TAG, mNavigationDrawerFragment.getArguments().toString());
  
          // Set up the drawer.
          mNavigationDrawerFragment.setUp(
                  R.id.navigation_drawer,
                  (DrawerLayout) findViewById(R.id.drawer_layout));
  
      }
  </code></pre>
  
  <p>The fragment code is as follows, it is only instantiating and trying to pull arguments:</p>
  
  <pre><code>@Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  
          ArrayList&lt;String&gt; strtext = getArguments().getStringArrayList("edttext");
  
          Log.i(TAG, strtext.toString());
  
          mDrawerListView = (ListView) inflater.inflate(
                  R.layout.fragment_navigation_drawer, container, false);
  
          mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
                  selectItem(position);
              }
          });
  
          mDrawerListView.setAdapter(new ArrayAdapter&lt;String&gt;(
                  getActionBar().getThemedContext(),
                  android.R.layout.simple_list_item_activated_1,
                  android.R.id.text1,
                  strtext));
  
          mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
          return mDrawerListView;
      }
  </code></pre>
  
  <p>Here is the content view being referenced this is the code being called on <code>SetContentView</code>:</p>
  
  <pre><code>&lt;android.support.v4.widget.DrawerLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/drawer_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context=".drawer"&gt;
  
      &lt;!-- As the main content view, the view below consumes the entire
           space available using match_parent in both dimensions. --&gt;
      &lt;FrameLayout
          android:id="@+id/container"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  
      &lt;!-- android:layout_gravity="start" tells DrawerLayout to treat
           this as a sliding drawer on the left side for left-to-right
           languages and on the right side for right-to-left languages.
           If you're not building against API 17 or higher, use
           android:layout_gravity="left" instead. --&gt;
      &lt;!-- The drawer is given a fixed width in dp and extends the full height of
           the container. --&gt;
      &lt;fragment
          android:id="@+id/navigation_drawer"
          android:layout_width="@dimen/navigation_drawer_width"
          android:layout_height="match_parent"
          android:layout_gravity="start"
          android:name="org.tcnjteamandroid.cryptochat.NavigationDrawerFragment"
          tools:layout="@layout/fragment_navigation_drawer" /&gt;
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>Finally, here is the stack trace:</p>
  
  <pre><code>04-02 17:59:57.897  23321-23321/org.tcnjteamandroid.cryptochat E/AndroidRuntime﹕ FATAL EXCEPTION: main
      Process: org.tcnjteamandroid.cryptochat, PID: 23321
      java.lang.RuntimeException: Unable to start activity ComponentInfo{org.tcnjteamandroid.cryptochat/org.tcnjteamandroid.cryptochat.drawer}: android.view.InflateException: Binary XML file line #24: Error inflating class fragment
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2299)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2361)
              at android.app.ActivityThread.access$800(ActivityThread.java:145)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1279)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5240)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
       Caused by: android.view.InflateException: Binary XML file line #24: Error inflating class fragment
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
              at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
              at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
              at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
              at org.tcnjteamandroid.cryptochat.drawer.onCreate(drawer.java:56)
              at android.app.Activity.performCreate(Activity.java:5933)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2252)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2361)
              at android.app.ActivityThread.access$800(ActivityThread.java:145)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1279)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5240)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
       Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.ArrayList android.os.Bundle.getStringArrayList(java.lang.String)' on a null object reference
              at org.tcnjteamandroid.cryptochat.NavigationDrawerFragment.onCreateView(NavigationDrawerFragment.java:100)
              at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
              at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:920)
              at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
              at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1206)
              at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2159)
              at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:297)
              at android.support.v7.app.ActionBarActivity.onCreateView(ActionBarActivity.java:547)
              at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
              at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
              at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
              at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:228)
              at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)
              at org.tcnjteamandroid.cryptochat.drawer.onCreate(drawer.java:56)
              at android.app.Activity.performCreate(Activity.java:5933)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2252)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2361)
              at android.app.ActivityThread.access$800(ActivityThread.java:145)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1279)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5240)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
  </code></pre>
  
  <p>Thanks in advance!</p>