title: How to Open New Screen in Android
body: <p>I am following this article to learn how to open new screen on button click:<br>
  <a href="http://learnandroid.blogspot.com/2008/01/opening-new-screen-in-android.html" rel="nofollow">http://learnandroid.blogspot.com/2008/01/opening-new-screen-in-android.html</a></p>
  
  <p><strong>But I am getting 3 error messages like this:</strong></p>
  
  <pre><code>      Description   Resource    Path    Location    Type
  R cannot be resolved to a variable  screen1.java    /screen1/src/test/android   line 20 Java Problem
  R cannot be resolved to a variable  screen1.java    /screen1/src/test/android   line 21 Java Problem
  R cannot be resolved to a variable  screen2.java    /screen1/src/test/android   line 13 Java Problem
  R cannot be resolved to a variable  screen2.java    /screen1/src/test/android   line 14 Java Problem
  Unparsed aapt error(s)! Check the console for output.   screen1     line 1  Android ADT Problem
  </code></pre>
  
  <p><strong>This is what I have done till now:</strong></p>
  
  <p><strong>screen1.java</strong></p>
  
  <pre><code>    package test.android;
  
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  
  
  
  
  public class screen1 extends Activity
  {
     public void onCreate(Bundle icicle)
     {
        super.onCreate(icicle);
        setContentView(R.layout.screen1);
        Button b = (Button)findViewById(R.id.btnClick);
        b.setOnClickListener(new View.OnClickListener() {
           public void onClick(View arg0) {
           Intent i = new Intent(screen1.this, screen2.class);
           startActivity(i);
           }
        });
     }
  }
  </code></pre>
  
  <p><strong>screen2.java</strong></p>
  
  <pre><code>    package test.android;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  
  public class screen2 extends Activity
  {
     public void onCreate(Bundle icicle)
     {
        super.onCreate(icicle);
        setContentView(R.layout.screen2);
        Button b = (Button) findViewById(R.id.btnClick2);
        b.setOnClickListener(new View.OnClickListener() {
           public void onClick(View arg0) {
           setResult(RESULT_OK);
           finish();
           }
        });
     }
  }
  </code></pre>
  
  <p><strong>AndroidManifest.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="test.android"
        android:versionCode="1"
        android:versionName="1.0"&gt;
  
  
      &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
       &lt;activity android:name=".Screen1" android:label="Screen 1"&gt;
          &lt;activity android:name=".screen1"
                    android:label="@string/app_name"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;/activity&gt;
          &lt;activity android:name=".Screen2"  android:label="Screen 2"&gt;
          &lt;/activity&gt;
  
      &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>screen1.xml</strong></p>
  
  <pre><code>   &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
  &gt;
  &lt;TextView
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:text="You are in the first Screen"
  /&gt;
  &lt;Button
     android:id ="@+id/btnClick"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="Open New Screen"
  /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>screen2.xml</strong></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
  &gt;
  &lt;TextView
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:text="You are in the New Screen"
  /&gt;
  &lt;Button
     android:id ="@+id/btnClick2"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="Close"
  /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>To give you an idea, this is screenshot of my project</p>
  
  <p><a href="http://img39.imageshack.us/img39/8883/projscreen.jpg" rel="nofollow">http://img39.imageshack.us/img39/8883/projscreen.jpg</a></p>
  
  <p><strong>Please help guys !</strong></p>