Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6139529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:00:04+00:00 2026-05-23T18:00:04+00:00

I am following this article to learn how to open new screen on button

  • 0

I am following this article to learn how to open new screen on button click:
http://learnandroid.blogspot.com/2008/01/opening-new-screen-in-android.html

But I am getting 3 error messages like this:

      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

This is what I have done till now:

screen1.java

    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);
         }
      });
   }
}

screen2.java

    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();
         }
      });
   }
}

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="test.android"
      android:versionCode="1"
      android:versionName="1.0">


    <application android:icon="@drawable/icon" android:label="@string/app_name">
     <activity android:name=".Screen1" android:label="Screen 1">
        <activity android:name=".screen1"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        </activity>
        <activity android:name=".Screen2"  android:label="Screen 2">
        </activity>

    </application>
</manifest>

screen1.xml

   <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
>
<TextView
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="You are in the first Screen"
/>
<Button
   android:id ="@+id/btnClick"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="Open New Screen"
/>

</LinearLayout>

screen2.xml

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
>
<TextView
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="You are in the New Screen"
/>
<Button
   android:id ="@+id/btnClick2"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="Close"
/>

</LinearLayout>

To give you an idea, this is screenshot of my project

http://img39.imageshack.us/img39/8883/projscreen.jpg

Please help guys !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:00:06+00:00Added an answer on May 23, 2026 at 6:00 pm

    Instead of setting your button ids as id ="@+id/btnClick" , use android:id ="@+id/btnClick"
    It is always a good idea to read the comments of the tutorials that you follow if you have problems, this fix was just 3-4 comments down.

    Also if you look at the line numbers referenced: 18 in screen1.java and 13 in screen2.java, you’ll find that the problem happens when you reference your button ids.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am following this article series to learn about ROLLUP and CUBE http://beyondrelational.com/modules/2/blogs/28/posts/10471/tsql-lab-6-using-with-cube-to-generate-subtotal-and-grand-total-rows.aspx For
In C following this article ( http://blogs.msdn.com/oldnewthing/archive/2006/12/21/1340571.aspx ), we have succesfully been able to
I'm new with cmake ,just installed it and following this article: http://www.cs.swarthmore.edu/~adanner/tips/cmake.php D:\Works\c\cmake\build>cmake ..
I am following this article (http://blogs.msdn.com/b/kaevans/archive/2011/04/11/intro-to-windbg-for-net-developers.aspx )and it is saying download symbols from Microsoft
In this article: http://msdn.microsoft.com/en-us/library/ms171728(VS.80).aspx The author uses the following method to make thread-safe calls
I have a gridview and have modified it following this article: http://msdn.microsoft.com/en-us/library/aa992036.aspx#Y3473 to allow
I'm following this article ( http://asciicasts.com/episodes/160-authlogic ), I'm not using nifty generator tho. I've
I was following this article: http://msdn.microsoft.com/en-us/library/aa902637%28v=sql.80%29.aspx and my query for distinct count looks like
I'm following this walkthrough: http://msdn.microsoft.com/en-us/library/879kf95c(VS.80).aspx In a machine running vista ultimate, I have installed:
I'm following this walktrough: http://msdn.microsoft.com/en-us/library/879kf95c.aspx to add user login and register pages using out-of-the-box

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.