title: RadioButton symbol not resolved in Android Studio
body: <p>I'm getting a &quot;cannot resolve symbol variable&quot; on <code>maleButton</code>, on the bottom where the femaleSelected is. I've defined the <code>RadioButton</code>s in <code>onCreate()</code>. I thought <code>onCreate()</code> was <code>protected</code>, and that's why I couldn't access the buttons. But changing it into <code>public</code> solves nothing.</p>
  <p>Here's the relevant code:</p>
  <pre><code>package ideaman924.playground;
  
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.RadioButton;
  
  public class MainActivity extends AppCompatActivity {
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          RadioButton maleButton,femaleButton;
          maleButton = (RadioButton) findViewById(R.id.male);
          femaleButton = (RadioButton) findViewById(R.id.female);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.menu_main, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          int id = item.getItemId();
  
          //noinspection SimplifiableIfStatement
          if (id == R.id.action_settings) {
              return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  
      public void femaleSelected(View view) {
          maleButton.toggle(); // error
      }
  
  }
  </code></pre>
  <p>Any idea why this is happening?</p>
  <p>EDIT: Here is also the XML layout:</p>
  <pre><code>&lt;LinearLayout
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:padding=&quot;16dp&quot;
      android:orientation=&quot;vertical&quot;&gt;
  
      &lt;TextView
          android:id=&quot;@+id/textView1&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginBottom=&quot;16dp&quot;
          android:text=&quot;Select gender&quot; /&gt;
  
      &lt;RadioButton
          android:id=&quot;@+id/female&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginBottom=&quot;16dp&quot;
          android:text=&quot;female&quot;
          android:onClick=&quot;femaleSelected&quot; /&gt;
  
      &lt;RadioButton
          android:id=&quot;@+id/male&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginBottom=&quot;16dp&quot;
          android:text=&quot;male&quot;
          android:onClick=&quot;maleSelected&quot; /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>