Because you wrote the return true
before that statement so that why this line TextView textView1 = (TextView) findViewById(R.id.textView1);
is unreachable because compiler wont reach to this statement.
Do like this
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
and Intialize the views in the onCreate
like
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView textView1 = (TextView) findViewById(R.id.textView1);
// you can set the text here any
}