Unable to setContentView with my tabhost with nested activities
<p>My code below is based on this: <a href="http://web.archive.org/web/20100816175634/http://blog.henriklarsentoft.com/2010/07/android-tabactivity-nested-activities/" rel="nofollow">http://web.archive.org/web/20100816175634/http://blog.henriklarsentoft.com/2010/07/android-tabactivity-nested-activities/</a>    </p>

<p>My issue is with the history ArrayList that is supposed to store the activities so I can properly utilize the back button, however my app crashes when I hit back. I think it's because history isn't exactly storing Views. </p>

<p>I added:</p>

<pre><code> View view = getLocalActivityManager().startActivity("ViewPagerActivity", new
                                                Intent(this,ViewPagerActivity.class)
                                                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
                                                .getDecorView();
</code></pre>

<p>to my back method to see if it would load it and it works.</p>

<pre><code>public class FeaturedTabGroup extends ActivityGroup {
         // Keep this in a static variable to make it accessible for all the nesten activities, lets them manipulate the view
            public static FeaturedTabGroup group;

        // Need to keep track of the history if you want the back-button to work properly, don't use this if your activities requires a lot of memory.
            private ArrayList history;



        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            this.history = new ArrayList();
            group = this;


         // Start the root activity withing the group and get its view
              View view = getLocalActivityManager().startActivity("ViewPagerActivity", new
                                                Intent(this,ViewPagerActivity.class)
                                                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
                                                .getDecorView();

                // Replace the view of this ActivityGroup
              replaceView(view);


        }


        public void replaceView(View v) {
            // Adds the old one to history
            history.add(v);
            // Changes this Groups View to the new View.
            setContentView(v);

            System.out.println("view set successful");
        }

        public void back() {

            if(history.size() &gt; 0) {
                history.remove(history.size()-1);
                setContentView((Integer) history.get(history.size()-1));
            }else {
                finish();
            }
        }

        @Override
        public void onBackPressed() {
            FeaturedTabGroup.group.back();
            return;
        }

    }
</code></pre>

<p>EDIT:</p>

<p>For brevity, I'll approach this problem with another question: why does setContentView(v) work, but not when the Views are store in an ArrayList? What happens to the view when it is stored in an arraylist?</p>
