Answer the question
In order to leave comments, you need to log in
How to solve "Cannot resolve symbol R" error in Android studio?
Lately, "Cannot resolve symbol R" error has started popping up in Android studio.
Help fix.
Ad Mob did not add, cleaning the project does not help.
The code in which the error appears:
package com.helloworldstudio.a4;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this, activity_second.class);
startActivity(intent);
}
public void onTap(View view) {
Intent intent = new Intent(MainActivity.this, activity_third.class);
startActivity(intent);
}
public void onContact(View view) {
EditText userEditText = (EditText) findViewById(R.id.editTextUser);
EditText giftEditText = (EditText) findViewById(R.id.editTextGift);
Intent intent = new Intent(MainActivity.this, activity_second.class );
intent.putExtra("username", userEditText.getText().toString());
intent.putExtra("gift", giftEditText.getText().toString());
startActivity(intent);
}
@SuppressLint("Registered")
class activity_second extends Activity {
@SuppressLint("SetTextI18n")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
String user = "Ничего";
String gift = "ничего";
user = getIntent().getExtras().getString("Username");
gift = getIntent().getExtras().getString("gift");
TextView infoTextView = (TextView)findViewById(R.id.textViewInfo);
infoTextView.setText(user + " , вам передали " + gift);
}
}
Answer the question
In order to leave comments, you need to log in
Or a resource problem. For example, somewhere not set a tag in xml.
class R is missing in the import section of the specified code. Your CO
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question