I want to update TextView
in onCreate()
, so that text should be set when Activity
Interface appears, what I've tried is:
Java Code:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sem_selection);
TextView T =(TextView)findViewById(R.id.textView1);
T.setText("required text");
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
}
but i get error when activity starts , as soon as i comment this line :
T.setText("required text");
App runs fine without error. How should I do this? Is there any other method?