Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find symbol variable TextView

I defined TextView like : TextView newTextView;

then compiling the line:

newTextView = (TextView) findViewById(R.id.textView);

Android-studio gives error > cannot find symbol variable newTextView? At the same time Studio is acting weird like this variable name won't go into the blue color, there is "j" icon by the class names in the project structure and similar. Anybody know what happened to my project?

like image 309
Nikanor Avatar asked Sep 20 '15 21:09

Nikanor


2 Answers

It's working on my code that I've tested it...

Just make sure that you've imported this :

import android.widget.TextView;

And then make a Clean project.

EDIT

It's a problem of your SDK so better solution is update it.

like image 122
Skizo-ozᴉʞS Avatar answered Oct 24 '22 08:10

Skizo-ozᴉʞS


If you're following the Google Android tutorial, when you create the second layout activity, and you pick a TextView widget, the ID of this widget it's "textView2".

You can:

Modify the findViewById() method and select the "textView2" view.

Or rename de ID of the view to "textView".

like image 32
Angel Luis Avatar answered Oct 24 '22 10:10

Angel Luis