I'm attempting Google University Android lab1 you are asked to change a TextView's text content according to the value passed via the Intent from another activity.
I tried out the rest of my code but... why does my app force close when I add the "tv.settext(...) line"?
public class HelloWorld extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*
* Fetch and display passed string.
*/
TextView tv = (TextView) findViewById(R.id.HelloTV);
Bundle extras = this.getIntent().getExtras();
if (extras != null) {
String nameStr = extras.get("Username").toString();
if (nameStr != null) {
tv.setText("Hello "+nameStr);
}
}
setContentView(R.layout.main);
}
}