Reputation: 21
setText(), setTextsize() and addView is not working. It is shown as cannot resolve symbol type.
Intent intent = getIntent();
String message = intent.getStringExtra(MyActivity.EXTRA_MESSAGE);
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
RelativeLayout layout = (RelativeLayout) findViewById(R.id.content);
layout.addView(textView);
Upvotes: 0
Views: 728
Reputation: 21
Intent intent = getIntent();
String message = intent.getStringExtra(MyActivity.EXTRA_MESSAGE);
TextView textView;
{
textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
}
RelativeLayout layout;
{
layout = (RelativeLayout) findViewById(R.id.content);
layout.addView(textView);
}
this solved my errors.
Upvotes: 0
Reputation: 499
Have you noticed this
``
At the end of this line
TextView textView = new TextView(this);``
Upvotes: 0
Reputation: 1502
You can't use methods such as add and find view by id before the layout is inflated. Verifý that setContentView is called before.
If it does, look at the value of message with a log.
Upvotes: 1