Загрузка данных


package com.example.yourapp // ваше имя пакета

import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {

    private var screen = 1 // 1, 2 или 3

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val text = findViewById<TextView>(R.id.textView)
        val button = findViewById<Button>(R.id.button)

        updateScreen(text, button)

        button.setOnClickListener {
            screen = when (screen) {
                1 -> 2
                2 -> 3
                else -> 1
            }
            updateScreen(text, button)
        }
    }

    private fun updateScreen(text: TextView, button: Button) {
        text.text = when (screen) {
            1 -> "Экран A"
            2 -> "Экран B"
            else -> "Экран C"
        }
        button.text = when (screen) {
            1 -> "Перейти на B"
            2 -> "Перейти на C"
            else -> "Назад на A"
        }
    }
}