using a button to switch between tabs
<p>Does anyone know how to create a button which will help me to switch between tabs?</p>

<pre><code>Button button1 = (Button) findViewById(R.id.button1);    
    button1.setOnClickListener(new OnClickListener() {  
        public void onClick(View v) {{
            // Perform action on click   
                if (v.getId() == R.id.button1) {
                    setContentView(R.layout.tab3);    
                }
                else if (v.getId() == R.id.button1) {
                    setContentView(R.layout.main);  
                }
            }
        }
    });
}}
</code></pre>

<p>this is the code in my tab 1,  this next code is the button in my tab.xml. i want to press the buy button below and i want it to go to another tab, is this possible?</p>

<pre><code>    &lt;Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignTop="@+id/imageButton1"
        android:text="Buy"  
        android:onClick="tab3" /&gt;
</code></pre>

<p>this is my logcat file </p>

<pre><code>01-05 16:04:20.903: D/dalvikvm(215): GC freed 806 objects / 70928 bytes in 96ms
01-05 15:30:29.072: D/AndroidRuntime(213): Shutting down VM
01-05 15:30:29.082: W/dalvikvm(213): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
01-05 15:30:29.082: E/AndroidRuntime(213): Uncaught handler: thread main exiting due to uncaught exception
01-05 15:30:29.132: E/AndroidRuntime(213): java.lang.IllegalStateException: Could not find a method tab3(View) in the activity
01-05 15:30:29.132: E/AndroidRuntime(213):  at android.view.View$1.onClick(View.java:2020)
01-05 15:30:29.132: E/AndroidRuntime(213):  at android.view.View.performClick(View.java:2364)
01-05 15:30:29.132: E/AndroidRuntime(213):  at android.view.View.onTouchEvent(View.java:4179)
01-05 15:30:29.132: E/AndroidRuntime(213):  at android.widget.TextView.onTouchEvent(TextView.java:6541)
01-05 15:30:29.132: E/AndroidRuntime(213):  at android.view.View.dispatchTouchEvent(View.java:3709)
01-05 16:04:25.693: E/AndroidRuntime(215):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-05 16:04:25.693: E/AndroidRuntime(215):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-05 16:04:25.693: E/AndroidRuntime(215):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-05 16:04:25.693: E/AndroidRuntime(215):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-05 16:04:25.693: E/AndroidRuntime(215):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-05 16:04:25.693: E/AndroidRuntime(215):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-05 16:04:25.693: E/AndroidRuntime(215):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-05 16:04:25.693: E/AndroidRuntime(215):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
01-05 16:04:25.693: E/AndroidRuntime(215):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
01-05 16:04:25.693: E/AndroidRuntime(215):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
01-05 16:04:25.693: E/AndroidRuntime(215):  at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
01-05 16:04:25.693: E/AndroidRuntime(215):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
01-05 16:04:25.693: E/AndroidRuntime(215):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
01-05 16:04:25.693: E/AndroidRuntime(215):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-05 16:04:25.693: E/AndroidRuntime(215):  at android.os.Looper.loop(Looper.java:123)
01-05 16:04:25.693: E/AndroidRuntime(215):  at android.app.ActivityThread.main(ActivityThread.java:4363)
01-05 16:04:25.693: E/AndroidRuntime(215):  at java.lang.reflect.Method.invokeNative(Native Method)
01-05 16:04:25.693: E/AndroidRuntime(215):  at java.lang.reflect.Method.invoke(Method.java:521)
01-05 16:04:25.693: E/AndroidRuntime(215):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-05 16:04:25.693: E/AndroidRuntime(215):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-05 16:04:25.693: E/AndroidRuntime(215):  at dalvik.system.NativeStart.main(Native Method)
01-05 16:04:25.693: E/AndroidRuntime(215): Caused by: java.lang.NoSuchMethodException: Tab3
01-05 16:04:25.693: E/AndroidRuntime(215):  at java.lang.ClassCache.findMethodByName(ClassCache.java:308)
01-05 16:04:25.693: E/AndroidRuntime(215):  at java.lang.Class.getMethod(Class.java:1014)
01-05 16:04:25.693: E/AndroidRuntime(215):  at android.view.View$1.onClick(View.java:2017)
01-05 16:04:25.693: E/AndroidRuntime(215):  ... 25 more
01-05 16:04:25.733: I/dalvikvm(215): threadid=7: reacting to signal 3
01-05 16:04:25.733: I/dalvikvm(215): Wrote stack trace to '/data/anr/traces.txt'
01-05 16:04:27.505: I/Process(215): Sending signal. PID: 215 SIG: 9
</code></pre>
