gatorpatch
gatorpatch

Reputation: 19

MyFirstApp android tutorial error on DisplayMessageActivity.java

I been following it and i am stuck on 3 textview errors tutorial:http://developer.android.com/training/basics/firstapp/starting-activity.html I get 2 error saying textView cannot be resolved and one saying textView cannot be resolved as a variable. help!

@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Get the message from the intent
    Intent intent = getIntent();
    String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);

    // Create the text view
    TextView textview = new TextView(this);
    textView.setTextSize(40);
    textView.setText(message);

    // Set the text view as the activity layout
    setContentView(textView);

    setContentView(R.layout.activity_display_message);
    // Show the Up button in the action bar.
    setupActionBar();

`

Upvotes: 1

Views: 1398

Answers (2)

Jainendra
Jainendra

Reputation: 25153

Variables in Java are case sensitive, so textView and textview are different. Change your code to this:

TextView textview = new TextView(this);
textview.setTextSize(40);
textview.setText(message);

// Set the text view as the activity layout
setContentView(textview);

Upvotes: 0

Ken Wolf
Ken Wolf

Reputation: 23269

You've declared it as textview (lowercase "v") but are referencing it as textView (uppercase "v"). Pick one!

TextView textView = new TextView(this); // Change the "v" to uppercase
textView.setTextSize(40);
textView.setText(message);

Upvotes: 3

Related Questions