Android: how to switch from 1 view to another?
<p>I just started learning Android yesterday and would like to code a very simple app that consists of 2 views for learning purpose.</p>

<p>Activity/View 1: 1 button and a text "Hello World"
On clicking the button, it should go to the next activity/view which only has text "testing".</p>

<p>Here's my code for activity 1:</p>

<pre><code>package helloworld.app;


import android.os.Bundle; 
import android.app.Activity; 
import android.view.Menu; 
import android.view.MenuItem; import
android.support.v4.app.NavUtils; 
/*import AudioRecordTest;*/

public class MainActivity extends Activity {

 @Override
 public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.activity_main);
 }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
     getMenuInflater().inflate(R.menu.activity_main, menu);
     return true;
 }

 public void startRecording() {
    setContentView(R.layout.next_page);
 }
  }
</code></pre>

<p>Here's my code for activity 2:
    package helloworld.app;</p>

<pre><code>import android.os.Bundle; 
import android.app.Activity; import
android.view.Menu; 
import android.view.MenuItem; import
android.support.v4.app.NavUtils; 
/*import AudioRecordTest;*/

public class next_page extends Activity {

 @Override
 public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.next_page);
 } }
</code></pre>

<p>Here's my code for xml file for activity 1:</p>

<pre><code>&lt;RelativeLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent" &gt;

 &lt;TextView
     android:id="@+id/textView1"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_centerHorizontal="true"
     android:layout_centerVertical="true"
     android:padding="@dimen/padding_medium"
     android:text="@string/hello_world"
     tools:context=".MainActivity" /&gt;

 &lt;Button
     android:id="@+id/button1"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentTop="true"
     android:layout_alignRight="@+id/textView1"
     android:layout_marginRight="40dp"
     android:layout_marginTop="32dp"
     android:text="Start Recording"
     android:onClick="startRecording" /&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p>EDIT:
Here are my error messages from logcat</p>

<blockquote>
  <p>08-01 07:00:49.253: I/Choreographer(1326): Skipped 40 frames!  The
  application may be doing too much work on its main thread.</p>
  
  <p>08-01 07:01:11.653: D/AndroidRuntime(1326): Shutting down VM</p>
  
  <p>08-01 07:01:11.653: W/dalvikvm(1326): threadid=1: thread exiting with
  uncaught exception (group=0x40a13300)</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326): FATAL EXCEPTION: main</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326):
  java.lang.IllegalStateException: Could not find a method
  startRecording(View) in the activity class helloworld.app.MainActivity
  for onClick handler on view class android.widget.Button with id
  'button1'</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326):   at
  android.view.View$1.onClick(View.java:3578)</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326):   at
  android.view.View.performClick(View.java:4084)</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326):   at
  android.view.View$PerformClick.run(View.java:16966)</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326):   at
  android.os.Handler.handleCallback(Handler.java:615)</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326):   at
  android.os.Handler.dispatchMessage(Handler.java:92)</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326):   at
  android.os.Looper.loop(Looper.java:137)</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326):   at
  android.app.ActivityThread.main(ActivityThread.java:4745)</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326):   at
  java.lang.reflect.Method.invokeNative(Native Method)</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326):   at
  java.lang.reflect.Method.invoke(Method.java:511)</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326):   at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326):   at
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326):   at
  dalvik.system.NativeStart.main(Native Method)</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326): Caused by:
  java.lang.NoSuchMethodException: startRecording [class
  android.view.View]</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326):   at
  java.lang.Class.getConstructorOrMethod(Class.java:460)</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326):   at
  java.lang.Class.getMethod(Class.java:915)</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326):   at
  android.view.View$1.onClick(View.java:3571)</p>
  
  <p>08-01 07:01:11.673: E/AndroidRuntime(1326):   ... 11 more</p>
</blockquote>

<p>EDIT2:
I found my mistake! I am supposed to pass in View view for my startRecording function. Here's the edited code:</p>

<pre><code>public void startRecording(View view) 
{
Intent intent = new Intent(this, next_page.class);  
startActivity(intent); 
}
</code></pre>
