Created
April 6, 2019 17:56
-
-
Save gfreivasc/412e9f5978bc76511248192de8cba6cc to your computer and use it in GitHub Desktop.
Second v
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : ComponentActivity(R.layout.activity_main) { | |
private var count: Int = 0 | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
savedInstanceState?.let { state -> | |
count = state.getInt("COUNT", 0) | |
} | |
textView.text = "$count" | |
button.setOnClickListener { | |
count++ | |
textView.text = "$count" | |
} | |
} | |
override fun onSaveInstanceState(outState: Bundle) { | |
outState.putInt("COUNT", count) | |
super.onSaveInstanceState(outState) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment