I'm trying the very first tutorial on the android website here
The goal is to enter a text and ship it to a next page to display it.
However, I always get "Unfortunately My First App has stopped".
I noticed that when I comment out setContentView(textView); it works.
Here is my code: (LogCat stopped showing problems for some reason so I can't give the log)
package com.example.myfirstapp; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v7.app.ActionBarActivity; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; public class DisplayMessageActivity extends ActionBarActivity { @Override protected void onCreate(Bundle 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); super.onCreate(savedInstanceState); setContentView(R.layout.activity_display_message); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction() .add(R.id.container, new PlaceholderFragment()).commit(); } }
super.onCreate(savedInstanceState); setContentView(R.layout.activity_display_message);