How can resolve R in Android?
<p>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.</p>

<pre><code>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 &lt; numberToGuess){
                Toast.makeText(GuessGame.this, "You guess is to low", Toast.LENGTH_SHORT).show();
            }
            else if(guess &gt; 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);
   }
</code></pre>

<p>}</p>

<p><em><strong>Edited:</em></strong> </p>

<p><strong>Tricks to solve this problem:</strong> </p>

<blockquote>
  <p>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.</p>
</blockquote>

<p>More details Solution go to : <a href="http://google-androidlovers.blogspot.com/search/label/R%20cannot%20be%20resolved%20to%20a%20variable" rel="nofollow">Details Solution about this article</a></p>
