title: Using button to open new view
body: <p>I have two applications that I want to combine.  One finds the sizes of pipes and one finds the sizes of tubing.  Both these applications work individually but I want to combine them so that when the new application initially gives the user a simple view with two buttons so they can choose whether they want pipe or tubing. Setting up this two button view is easy, but calling the other views associated with the two separate other applications is what I am having problems with.</p>
  
  <p>For example my .java file for the individual applications is something like this:</p>
  
  <pre><code>package com.examples.pipe;
  
  import com.examples.pipe.R;
  
  import android.app.Activity;
  import android.content.Context;
  import android.content.SharedPreferences;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.ArrayAdapter;
  import android.widget.Spinner;
  import android.widget.TextView;
  import android.widget.Toast;
  import android.widget.AdapterView.OnItemSelectedListener;
  
  
  public class pipe extends Activity {
  
  
  
      /**
       * Initialize a bunch of stuff
       */
      @Override
      public void onCreate(Bundle savedInstanceState) {
  
          /**
           * derived classes that use onCreate() overrides must always call the super constructor
           */
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.main);
  
          Spinner spinner = (Spinner) findViewById(R.id.Spinner01);
  
       /**
       * Do a bunch of calculations and post the results in main.xml
       */
  </code></pre>
  
  <p>Similar code for tubing application.  I initially thought that making my com.examples.pipe and com.examples.tubing applications libraries called by a simple button applications would be the best way to do this but could not figure it out (the tictactoe example on the android site seemed much more complicated than what I wanted to do).</p>
  
  <p>I thought I could just make another application, button_call, with the onCreate of this new application calling </p>
  
  <pre><code>setContentView(R.layout.button_main);
  </code></pre>
  
  <p>and then use an onClick to call the .xml files in the layout folder for the individual applications I have already written.  Alas, I have not found a way to do this.  </p>
  
  <p>I have this application written on Palm Pre (http://www.myappbox.com/search/?q=pipe+and+tube) but am trying to develop it for android though the code is not altogether similar when is comes to calling different views.</p>