Search code examples
javaandroidandroid-studiocompiler-errorstextview

cannot find symbol textView AndroidStudio


I am trying to Pass Data from One Activity to Another Activity in that when when I am writing code to get data in Text View then Showing an error to textView Can Anyone Tell me how resolve this error. I am pasting my code Here Please Check and Tell me. Error At Line Number 12, 14 and 16. at starting "textView"

Error Compiler Showing is :

error: cannot find symbol textView.setText(NameRecive);

symbol: variable textView

location: class barcode_genrator

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

    Intent intent = getIntent();
    String NameRecive = intent.getStringExtra(activity_DataEntry.NAME_TO_SEND);
    String SurnameRecive = intent.getStringExtra(activity_DataEntry.SURNAME_TO_SEND);
    String NumberRecive = intent.getStringExtra(activity_DataEntry.NUMBER_TO_SEND);

    TextView name = findViewById(R.id.FN);
    textView.setText(NameRecive);
    TextView surname = findViewById(R.id.LN);
    textView.setText(SurnameRecive);
    TextView number = findViewById(R.id.MN);
    textView.setText(NumberRecive);
}

Solution

  • The names of the variables you declared are name, surname and number, respectively, not textView:

    TextView name = findViewById(R.id.FN);
    name.setText(NameRecive); // Here
    TextView surname = findViewById(R.id.LN);
    surname.setText(SurnameRecive); // And here
    TextView number = findViewById(R.id.MN);
    number.setText(NumberRecive); // And here