0

I am making a quiz taking app, below is my java code.The "id" shows red color and gives the error "Error:(33, 52) error: cannot find symbol variable id "besides I have defined for each text view an id,and I have cleaned and rebuild the project but it is not working. enter image description here

package com.example.android.myupdatedproject;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Toast;



 public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

      int count = 0;


    public void solutionAnswer(View view)
    {


        RadioButton R = (RadioButton)findViewById(R.id.karachi);
        boolean R1 =  R.isChecked();

        RadioButton S = (RadioButton)findViewById(R.id.urdu);
        boolean S1 =  S.isChecked();

        RadioButton T = (RadioButton)findViewById(R.id.jinnah);
        boolean T1 =  T.isChecked();

        RadioButton U = (RadioButton)findViewById(R.id.jasmine);
        boolean U1 =  U.isChecked();



       switch (view.getId())
        {
            case R.id.karachi:
                if(R1)
                {
                    count++;
                    //Toast.makeText(this, "Correct", Toast.LENGTH_SHORT).show();
                    return;
                }
            case R.id.jasmine:
                if(U1)
                {
                    count++;
                    //Toast.makeText(this, "Correct", Toast.LENGTH_SHORT).show();
                    return;
                }
            case R.id.urdu:
                if(S1)
                {
                    count++;
                    //Toast.makeText(this, "True", Toast.LENGTH_SHORT).show();
                    return;
                }
        }
    }

    public void total(View view)
    {
        EditText A = (EditText)findViewById(R.id.usa);
        String A1= A.getText().toString();

        EditText B = (EditText)findViewById(R.id.google);
        String B1= B.getText().toString();

        EditText C = (EditText)findViewById(R.id.apple);
        String C1= A.getText().toString();
        if(A1 == "Donald Trump")
        {
            count++;
        }
        if(B1 == "USA")
        {
            count++;
        }
        if(C1 == "Steve Jobs")
        {
            count++;
        }

        Toast.makeText(this, "Your score is = "+count, Toast.LENGTH_SHORT).show();
}

}

screenshot of the errors

Anna Rose
  • 11
  • 4

2 Answers2

0

Import the R file of your project and then Rebuild the Project.

0

first import the R class like import com.yourpkg.R; than Just Click on Build ->clean-> Rebuild Project option in your Android Studio.

if it will not work than Restart your IDE or try

Invalidate Caches/ Restart enter image description here

AskNilesh
  • 67,701
  • 16
  • 123
  • 163