title: Is it possible to create a array with views
body: <p>I try to make something like this: </p>
  
  <pre><code>public static ArrayList&lt;View&gt; rootView = new ArrayList&lt;View&gt;();
  </code></pre>
  
  <p>But when i try to add view to it I just get a null pointer exception which makes me wonder if i do something wrong or if it just isn't possible to do this?</p>
  
  <p>Thanks.</p>
  
  <p>Code : </p>
  
  <pre><code> ArrayList&lt;View&gt; rootView = new ArrayList&lt;View&gt;();
  View v=inflater.inflate(R.layout.activity_main, null);
  rootView.add(v);
  </code></pre>
  
  <p>The rootView.add(v); just makes a null pointer exception</p>
  
  <p>Logcat added:</p>
  
  <pre><code>  03-19 20:49:35.543: E/AndroidRuntime(8755): FATAL EXCEPTION: main
  03-19 20:49:35.543: E/AndroidRuntime(8755): java.lang.NullPointerException
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at code94.message.TestFragment.onCreateView(TestFragment.java:113)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:461)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.support.v4.view.ViewPager.populate(ViewPager.java:1011)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.support.v4.view.ViewPager.populate(ViewPager.java:880)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1374)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.view.View.measure(View.java:15517)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:681)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.view.View.measure(View.java:15517)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.view.View.measure(View.java:15517)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.view.View.measure(View.java:15517)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2313)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.view.View.measure(View.java:15517)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1874)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1089)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1265)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.view.Choreographer.doCallbacks(Choreographer.java:562)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.view.Choreographer.doFrame(Choreographer.java:532)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.os.Handler.handleCallback(Handler.java:725)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.os.Handler.dispatchMessage(Handler.java:92)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.os.Looper.loop(Looper.java:137)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at android.app.ActivityThread.main(ActivityThread.java:5228)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at java.lang.reflect.Method.invokeNative(Native Method)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at java.lang.reflect.Method.invoke(Method.java:511)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
  03-19 20:49:35.543: E/AndroidRuntime(8755):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>