TabActivity with multiple nested acitivities based on Button Click
<p>The problem I face is how to navigate through tab activity with nested
activities based on Button click android.</p>

<p>I have 3 tabs Dashboard, Vehicle search, and Location search. When I
press the location search tab I get a Edit text(to enter the zip code)
and  go button(when I press it I should get the locations in 100 miles
of zip code in different page called Location Search Results page)</p>

<p>My specific problem is the app crashes when I press go button and
before I get the locations</p>

<p>I have MainActivity class which extends the TabActivity and define all
the tabs</p>

<pre><code>public class MainActivity extends TabActivity
{
     public TabHost tabHost;
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main);
       tabHost = (TabHost) findViewById(android.R.id.tabhost);
       TabHost.TabSpec spec;
       Intent intent;

       intent = new Intent().setClass(this, DashBoard.class);
       spec =
tabHost.newTabSpec("dashboard").setIndicator("DashBoard").setContent(intent);
       tabHost.addTab(spec);

       intent = new Intent().setClass(this, VehicleSearch.class);
       spec =
tabHost.newTabSpec("vehicleSearch").setIndicator("VehicleSearch").setContent(intent);
       tabHost.addTab(spec);

       intent = new Intent().setClass(this, BranchSearch.class);
       spec =
tabHost.newTabSpec("branchSearch").setIndicator("BranchSearch").setContent(intent);
       tabHost.addTab(spec);

       tabHost.setCurrentTab(3);


}
</code></pre>

<p>I also have the BranchSearchHelper class which extends ActivityGroup</p>

<pre><code>public class BranchSearchHelper extends ActivityGroup
{
     public static BranchSearchHelper branchSearch;
     private ArrayList&lt;View&gt; history;
     @Override
   public void onCreate(Bundle savedInstanceState)
     {
       super.onCreate(savedInstanceState);
       branchSearch = this;
       this.history = new ArrayList&lt;View&gt;();


       View view =
getLocalActivityManager().startActivity("BranchSearch", new
Intent(this,BranchSearch.class)
                 .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();

       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);
     }

      public void back()
      {
                    if(history.size() &gt; 0) {
                        history.remove(history.size()-1);

setContentView(history.get(history.size()-1));
                    }
                    else
                    {
                        finish();
                    }
}

               @Override
               public void onBackPressed()
               {

                 BranchSearchHelper.branchSearch.back();
                    return;
                }


}
</code></pre>

<p>The class BranchSearch extends Activity</p>

<pre><code>public class BranchSearch extends Activity implements OnClickListener
{

     public void onCreate(Bundle savedInstanceState)
     {
             super.onCreate(savedInstanceState);
             setContentView(R.layout.branchsearch);
             Button locSearch = (Button)
findViewById(R.id.btnlocSearch);
             locSearch.setOnClickListener(this);


         }

      public void onClick(View v)
     {
                 // TODO Auto-generated method stub

                 EditText editText = (EditText)
findViewById(R.id.lsearch);

                 Bundle bundle = new Bundle();
                 bundle.putString("zipCode",
editText.getText().toString() );

                 Intent i = new Intent(getApplicationContext(),
LocationSearchResults.class);
                 i.putExtras(bundle);
                 i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);


                View view =
BranchSearchHelper.branchSearch.getLocalActivityManager().startActivity("Locations
Results",i).getDecorView();

                 BranchSearchHelper.branchSearch.replaceView(view);




           }


}
</code></pre>

<p>I always get an javaNUllPointerexception the exception throws at</p>

<pre><code>View view =
BranchSearchHelper.branchSearch.getLocalActivityManager().startActivity("Locations
Results",i).getDecorView();
</code></pre>

<p>because branchSearch is null</p>

<p>so can you please tell me how I can keep the track of tabs and show
the all the location results when I press the go button without
crashing the application. ( what parts of code should I change)</p>

<p>There is a class called LocationSearchResults which handles the
displaying of all location search results</p>
