title: How to navigate from one page to another on android?(Total:3 pages)
body: <p>I am new to Android development and I have a question regarding how to navigate from one page to another.
  Actually,what I want to do is this:
  Open app,first page appears,it says "Hello I am activity 1".Then there is a button which says "Next",you press next then you navigate to second page where it says "Hello I am activity 2".In this page there are two buttons,first says "Previous" which takes you back to page 1 and second says "Next" which takes you to page 3.
  Basically,this is where I am stuck,page 1 and 2 works fine,both next and previous buttons but I can't navigate to 3rd page when I press the "next" button from page 2.
  I have uploaded my source code here so you guys can download it and import it to Eclipse in order to see exactly what I have done.</p>
  
  <p>Click <a href="http://www.2shared.com/file/ZkTxfWlb/Test.html/" rel="nofollow">here</a> to download.</p>
  
  <p>Would be glad if someone could help mates,
  Thanks in advance.</p>
  
  <p>OK,code is shown here,I have created 3 activities which I also registered at Manifest and I also have created 3 layouts for these 3 activities.</p>
  
  <p><strong>Activity 1</strong></p>
  
  <pre><code>import android.app.Activity;&lt;br&gt;
  import android.content.Intent;&lt;br&gt;
  import android.os.Bundle;&lt;br&gt;
  import android.view.View;&lt;br&gt;
  import android.widget.Button;&lt;br&gt;
  
  public class Activity1 extends Activity {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
           setContentView(R.layout.main);
  
          Button next = (Button) findViewById(R.id.Button01);
          next.setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) {
                  Intent myIntent = new Intent(view.getContext(), Activity2.class);
                  startActivityForResult(myIntent, 0);
              }
  
          });
      }
  }
  </code></pre>
  
  <p><strong>Activity2</strong></p>
  
  <pre><code>import android.app.Activity;&lt;br&gt;
  import android.content.Intent;&lt;br&gt;
  import android.os.Bundle;&lt;br&gt;
  import android.view.View;&lt;br&gt;
  import android.widget.Button;&lt;br&gt;
  
  public class Activity2 extends Activity {
  
      /** Called when the activity is first created. */
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main2);
  
          Button next = (Button) findViewById(R.id.Button02);
          next.setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) {
                  Intent intent = new Intent();
                  setResult(RESULT_OK, intent);
                  finish();
              }
  
          });
      }
  
  
  public void onCreate1(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
       setContentView(R.layout.main2);
  
      Button next = (Button) findViewById(R.id.Button04);
      next.setOnClickListener(new View.OnClickListener() {
          public void onClick(View view) {
              Intent myIntent1 = new Intent(view.getContext(), Activity3.class);
              startActivityForResult(myIntent1, 0);
          }
  
      });
  }
  }
  </code></pre>
  
  <p><strong>Activity3</strong></p>
  
  <pre><code>import android.app.Activity;&lt;br&gt;
  import android.content.Intent;&lt;br&gt;
  import android.os.Bundle;&lt;br&gt;
  import android.view.View;&lt;br&gt;
  import android.widget.Button;&lt;br&gt;
  
  public class Activity3 extends Activity {
  
      /** Called when the activity is first created. */
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main3);
  
          Button next = (Button) findViewById(R.id.Button04);
          next.setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) {
                  Intent intent = new Intent();
                  setResult(RESULT_OK, intent);
                  finish();
              }
  
          });
      }
  }
  </code></pre>
  
  <p><strong>main.xml</strong></p>
  
  <pre><code>  &lt;TextView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:textColor="#000000"
      android:text="This is Activity 1" /&gt;
  
         &lt;Button android:text="Next"
          android:id="@+id/Button01"
          android:layout_width="250px"
              android:textSize="18px"
          android:layout_height="55px"&gt;
      &lt;/Button&gt;    
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>main2.xml</strong></p>
  
  <pre><code>    &lt;TextView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:textColor="#000000"
      android:text="This is Activity 2" /&gt;
  
         &lt;Button android:text="Previous"
          android:id="@+id/Button02"
          android:layout_width="250px"
              android:textSize="18px"
          android:layout_height="55px"&gt;
      &lt;/Button&gt;
  
  
  
         &lt;Button
             android:layout_width="162dp"
             android:layout_height="34dp"
             android:text="Next"
             android:id="@+id/Button04"
             android:textSize="18px" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>main3.xml</strong></p>
  
  <pre><code>&lt;TextView
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:textColor="#000000"
  android:text="This is Activity 3" /&gt;
  </code></pre>
  
  <p>I have also registered my activities in Manifest.</p>