I just started experimenting with Android app development and so I decided to give Android’s own tutorials a go (this one: http://developer.android.com/training/basics/firstapp/starting-activity.html )
The textview in my new activity just won’t show. Here’s my code:
public class DisplayMessageActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/* Get the intent and the message sent with it */
Intent intent = getIntent();
String message = intent.getStringExtra(GoogleTutActivity.EXTRA_MESSAGE);
/* Create a new textview where we can show the message the user sent */
TextView textView = new TextView(this);
textView.setTextSize(40);
textView.setText(message);
setContentView(R.layout.activity_display_message);
}
}
you didn’t add the textview to layout.
1.
setContentView(textView);2. or add textview to the xml activity_display_message and set id.
then