I have started coding in java/android just today so excuse me if I am being a total idiot here.
I have been facing this problem for the past hour, I have tried to go
Declare it as a variable of your activity and initialize it after calling setContentView()
. There is no need to pass a View parameter in your function if you're just setting the text of your TextView
.
public class MainActivity extends Activity {
private TextView test;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_launch);
test = (TextView)findViewById(R.id.textView2);
registermessage();
}
public void registermessage() {
test.setText("Test");
}