Reputation: 262
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?
Upvotes: 5
Views: 18256
Reputation: 121
What you can do is go to design view (in the activity) and select the TextView and make the ID for it as 'TextView'.It worked for me!!
Upvotes: 0
Reputation: 1
Make sure you selected the right widget. For me one issue is that in activity_display_message.xml I originally inserted a Text/Plain Text instead of a Text/Textview widget.
Autocomplete R.id then helped me to select the proper id of the textview, and of the editText in MainActivity
EditText editText = (EditText) findViewById(R.id.editText4);
Upvotes: 0
Reputation: 1
Used autocomplete to correct this. The variable name in my case was textView3
Upvotes: -1
Reputation: 322
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".
Upvotes: 4
Reputation: 373
I used to magic of autocomplete to find that this is the correct attribute: -
R.id.textView2
I'm working through the tutorial myself, somewhat confusing I know.
Upvotes: -1
Reputation: 20646
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.
It's a problem of your SDK so better solution is update it.
Upvotes: 7