I'm trying to set multiple TextView by calling setText on my TextView from my MainActivity.java
but I get an error (null object) because (I guess) my setContentView is pointed on R.id.first_layout
and one of the TextView is in another layout (let's say R.id.second_layout
).
How could I setText on those 2 differents layout in my MainActivity ?
I tried the following code but nothing change when I launch the app :
LayoutInflater inflater = getLayoutInflater();
View navHeaderView = inflater.inflate(R.layout.second_layout, null);
nameTextView = (TextView)
navHeaderView.findViewById(R.id.nameTextView);
nameTextView.setText("Test")