Both activities are in the same package
Second activity uses second layout file
setContentView(R.layout.main2);
Errors on this line
It is due to typecast error. You have to try this- TextView.setText(Integer.toString(variable_name));
Here toString is used to convert integer to string for showing text.