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 6213097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:38:08+00:00 2026-05-24T06:38:08+00:00

I was run the program to guess random number but in case R, their

  • 0

I was run the program to guess random number but in case R, their should be “R cannot be resolved to a variable” error comes many time . And i am also try to import android.R; but could not work without errorless. error comes in to “main” or “R.layout.main”. so please fix the problem.

public class GuessGame extends Activity {
    Button btnGuess;
   private EditText enter;
   private GuessGame mcontext;
   private Double guess;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final Random rand= new Random();
    final int numberToGuess= rand.nextInt(20);
    int numberOfTries=0;

        final boolean win= false;
        btnGuess= (Button)findViewById(R.id.btnGuess);
        enter= (EditText)findViewById(R.id.EnterNumber);

        TextView tv= (TextView) findViewById(R.id.dislpayResult);
        guess=new Double(enter.getText().toString());


     btnGuess.setOnClickListener(new OnClickListener() {
         private AlertDialog show;
         @Override
            public void onClick(View v) {
             while(win == false){
                 if((enter.getText().length() == 0) || (enter.getText().toString() == "")){

                     show= new AlertDialog.Builder(mcontext).setTitle("Error Was Found")
                        .setMessage("Input are Emppty")
                        .setPositiveButton("Ok", null).show();
            }
            else if(guess == numberToGuess){
                //win = true;
                Toast.makeText(GuessGame.this, "You have win", Toast.LENGTH_SHORT).show();
            }
            else if(guess < numberToGuess){
                Toast.makeText(GuessGame.this, "You guess is to low", Toast.LENGTH_SHORT).show();
            }
            else if(guess > numberToGuess){
                Toast t=Toast.makeText(GuessGame.this, "You guess is to high", Toast.LENGTH_SHORT);
                t.show();
            }
          }
        }
    });
    tv.setText("You win");
    tv.setText("Yhe Number was" + numberToGuess);
    tv.setText("Tries times" + numberOfTries);
   }

}

Edited:

Tricks to solve this problem:

Once you have changed all the names of your resources, just clean the
project ( Project>Clean..), wait a few seconds, and your R.java file
will come back home. Getting the R.java file back should get rid of
most of your errors, but if it didn’t, check all your class’ imports
for the “import android.R” and if it is there, delete it and clean the
project.

More details Solution go to : Details Solution about this article

  • 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-24T06:38:09+00:00Added an answer on May 24, 2026 at 6:38 am

    The R.java file should be automatically generated by Android. Try the following:

    1. If you are using Eclipse try “project clean” to regenerate the file.
    2. Try to fix all errors not related to the R file and then retry the “project clean” option. Other errors (e.g. your xml layout files) can “stall” a new build of the R file via project clean.
    3. Make sure your project is an Android project and you have an android.jar file on your classpath.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How should I run another program from within my C program? I need to
I have a problem. When I run my program, it comes up with an
Some users are suggesting that my (C#) program should be able to run scripts
This is may be not program question, but i guess its program logic question.
I have errors when I run program(1). But when I used program(2), writing 0
I keep encountering this Debug assertions failed! error when I run my program in
I want to design a c# program which can run program a 3rd exe
To run a program with custom env settings, we do this on Linux $
When I run the program from IDE (VS2008) it works perfectly. When I want
When you run a program through the command line, you can use java -Xms

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.