Guest User

Untitled

a guest
Feb 15th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. package id.bukusaku.dillo
  2.  
  3. import android.os.Bundle
  4. import android.support.v7.app.AppCompatActivity
  5. import android.widget.Toast
  6. import kotlinx.android.synthetic.main.activity_main.*
  7.  
  8. class MainActivity : AppCompatActivity() {
  9.  
  10. private var score = 0
  11.  
  12. override fun onCreate(savedInstanceState: Bundle?) {
  13. super.onCreate(savedInstanceState)
  14. setContentView(R.layout.activity_main)
  15. btn_count.setOnClickListener { countScore() }
  16. btn_toast.setOnClickListener { showToast() }
  17. //btn_reset.setOnClickListener { resetScore() }
  18. }
  19.  
  20. /*private fun resetScore() {
  21. score = 0
  22. tv_score.text = score.toString()
  23. }*/
  24.  
  25. private fun showToast() {
  26. Toast.makeText(this, "Score is $score", Toast.LENGTH_LONG).show()
  27. }
  28.  
  29. private fun countScore() {
  30. score = tv_score.text.toString().toInt()
  31. score++
  32. tv_score.text = score.toString()
  33. }
  34. }
Add Comment
Please, Sign In to add comment