fixed rotate screen bug
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
package com.dano.test1
|
||||
|
||||
import android.content.res.Configuration
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
||||
@ -12,11 +13,20 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
// Initialize the opening screen handler and show the opening screen
|
||||
// Opening Screen nur beim echten Start initialisieren.
|
||||
// Durch configChanges wird onCreate bei Drehung NICHT erneut aufgerufen.
|
||||
openingScreenHandler = HandlerOpeningScreen(this)
|
||||
openingScreenHandler.init()
|
||||
}
|
||||
|
||||
// Wichtig: Bei Konfigurationsänderungen NICHT den Screen neu setzen.
|
||||
// So bleibt man auf der aktuellen Frage/Seite.
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
// Kein setContentView(), kein openingScreenHandler.init() hier!
|
||||
// Falls du Layout-Metriken bei Rotation neu berechnen willst, kannst du das gezielt hier tun.
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the given questionnaire and attaches it to this activity.
|
||||
* @param questionnaire The questionnaire instance to start.
|
||||
@ -44,7 +54,6 @@ class MainActivity : AppCompatActivity() {
|
||||
* Finish the questionnaire and return to the opening screen.
|
||||
*/
|
||||
fun finishQuestionnaire() {
|
||||
// For example, switch back to the opening screen:
|
||||
isInQuestionnaire = false
|
||||
isFirstQuestionnairePage = false
|
||||
openingScreenHandler.init()
|
||||
|
||||
Reference in New Issue
Block a user