Evgeny
Evgeny

Reputation: 107

Android studio cannot resolve symbol equals

I am making a simple mobile app. For now I am just testing the app and trying to pass some values in between java files and put them in empty TextViews. I get values from a previous activity via Intent and then trying to pass them on to another activity called ConsultActivity.java:

String username = getIntent().getStringExtra("Identifiant");
final TextView tv = (TextView)findViewById(R.id.TVUsername);
if(username.equals("marcel123")){
    tv.setText("M Dupond");
}
else if(username.equals("tommy1")){
    tv.setText("M Thompson");
}
else if(username.equals("emma89")){
    tv.setText("Mme Sinieux");
}

consult = (ImageView)findViewById(R.id.consult);

consult.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Intent i=new Intent(MainActivity.this,ConsultActivity.class);
        i.putExtra("Username", tv.getText().toString());
        startActivity(i);
    }
});

However in my ConsultActivity, when I am doing basically the same thing, my equals are highlighted and say "Cannot resolve symbol equals"

String name = getIntent().getStringExtra("Username");
final TextView textV = (TextView)findViewById(R.id.TVUsername2);
if(name.equals("M Dupond")){
    textV.setText("M Dupond");
}
else if(name.equals("M Thompson")){
    textV.setText("M Thompson");
}
else if(name.equals("Mme Sinieux")){
    textV.setText("Mme Sinieux");
}

Upvotes: 1

Views: 1960

Answers (1)

Jorgesys
Jorgesys

Reputation: 126455

Probably its just a Synchronization problem try with: Sych project with gradle files

enter image description here

Upvotes: 1

Related Questions