title: R cannot be resolved to a variable
body: <p>I would like to fix this error </p>
  
  <blockquote>
    <p>R cannot be resolved to a variable</p>
  </blockquote>
  
  <p>I looked up many answers, but I could not get the right one; I tried everything. Could any one help me?</p>
  
  <p>My main activity which is automatically created.  The error is showing for the three lines starting at <code>case R.id.button1:</code>:</p>
  
  <pre><code>package de.vogella.android.temprature1;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.EditText;
  import android.widget.RadioButton;
  import android.widget.Toast;
  
  public class Convert extends Activity {
      private EditText text;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          text = (EditText) findViewById(R.id.editText1);
      }
  
      // This method is called at button click because we assigned the name to the
      // "On Click property" of the button
      public void myClickHandler(View view) {
      switch (view.getId()) {
          case R.id.button1:
              RadioButton celsiusButton = (RadioButton) findViewById(R.id.radio0);
              RadioButton fahrenheitButton = (RadioButton) findViewById(R.id.radio1);
              if (text.getText().length() == 0) {
                  Toast.makeText(this, "Please enter a valid number",
                  Toast.LENGTH_LONG).show();
                  return;
              }
  
              float inputValue = Float.parseFloat(text.getText().toString());
              if (celsiusButton.isChecked()) {
                  text.setText(String.valueOf(convertFahrenheitToCelsius(inputValue)));
              } else {
                  text.setText(String.valueOf(convertCelsiusToFahrenheit(inputValue)));
              }
  
              // Switch to the other button
              if (fahrenheitButton.isChecked()) {
                  fahrenheitButton.setChecked(false);
                  celsiusButton.setChecked(true);
              } else {
                  fahrenheitButton.setChecked(true);
                  celsiusButton.setChecked(false);
              }
              break;
          }
      }
  
      // Converts to celsius
      private float convertFahrenheitToCelsius(float fahrenheit) {
          return ((fahrenheit - 32) * 5 / 9);
      }
  
      // Converts to fahrenheit
      private float convertCelsiusToFahrenheit(float celsius) {
          return ((celsius * 9) / 5) + 32;
      }
  }
  </code></pre>
  
  <p>my main.xml</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" android:background="@color/myColor"&gt;
      &lt;EditText android:layout_height="wrap_content" android:id="@+id/editText1"
          android:layout_width="match_parent" android:inputType="numberDecimal|numberSigned"&gt;&lt;/EditText&gt;
      &lt;RadioGroup android:layout_height="wrap_content" android:id="@+id/radioGroup1"
          android:layout_width="match_parent"&gt;
          &lt;RadioButton android:layout_width="wrap_content"
              android:id="@+id/radio0" android:layout_height="wrap_content"
              android:text="@string/celsius" android:checked="true"&gt;&lt;/RadioButton&gt;
          &lt;RadioButton android:layout_width="wrap_content"
              android:id="@+id/radio1" android:layout_height="wrap_content"
              android:text="@string/fahrenheit"&gt;&lt;/RadioButton&gt;
      &lt;/RadioGroup&gt;
      &lt;Button android:id="@+id/button1" android:layout_width="wrap_content"
          android:layout_height="wrap_content" android:text="@string/calc"
          android:onClick="myClickHandler"&gt;&lt;/Button&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>my string.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
      &lt;string name="hello"&gt;Hello World, Convert!&lt;/string&gt;
      &lt;string name="app_name"&gt;de.vogella.android.temprature1&lt;/string&gt;
  &lt;string name="myClickHandler"&gt;myClickHandler&lt;/string&gt;
  &lt;string name="celsius"&gt;to Celsius&lt;/string&gt;
  &lt;string name="farenheit"&gt;to Farenheit&lt;/string&gt;
  &lt;string name="calc"&gt;Calculate&lt;/string&gt;
  &lt;/resources&gt;
  </code></pre>