package com.example.myapplication
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
class MainActivity : ComponentActivity() {
private val testView: TestView = TestView()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
activity = this
setContent {
testView.TestFun()
}
}
companion object {
lateinit var activity: MainActivity
}
}
class TestView {
var name = mutableStateOf("")
var count = 0
init {
Timer().scheduleAtFixedRate(object : TimerTask() {
override fun run() {
count++
name.value = count.toString()
}
}, 1000L, 1000L)
}
@Composable
fun TestFun() {
val data = this
Column {
Text(text = data.name.value)
}
}
}