Alright guys, homework related question here. No, I don't need you to write code, but I'm hoping someone can help me understand why this works.
Inside my onCreate() function, I have this code
boolean layout = getResources().getConfiguration().orientation == 1;
TextView lo = findViewById(R.id.layout);
if (layout) {
lo.setText(R.string.port);
} else {
lo.setText(R.string.land);
}
It works correctly, and changes the string in the TextView as I expected it would on screen orientation change, but therein lays my problem. I thought (I'm guessing incorrectly) that each time you rotated the device, it was firing onCreate again, redrawing the screen.
Going ahead with this model in my mind that I found here, and looking to expand on it, I decided to set an int in the main activity, then increment it in onCreate(), and a TextView that would update each time the screen rotated as below.
TextView oc = findViewById(R.id.count);
num++;
oc.setText(valueOf(num));
to my dismay, it never increments past one, no matter how many times I rotate, while the orientation portion always fires.
Hopefully someone can educate me as to why the orientation fires on each rotate, but the other portion does not. Thanks ahead of time, flame away!