HICONT

mainActivity.kt

Sep 10th, 2024
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. package com.example.first_app_1
  2.  
  3. import android.os.Bundle
  4. import android.widget.Button
  5. import android.widget.TextView
  6. import androidx.activity.enableEdgeToEdge
  7. import androidx.appcompat.app.AppCompatActivity
  8. import androidx.core.view.ViewCompat
  9. import androidx.core.view.WindowInsetsCompat
  10.  
  11. class MainActivity : AppCompatActivity() {
  12. override fun onCreate(savedInstanceState: Bundle?) {
  13. super.onCreate(savedInstanceState)
  14. enableEdgeToEdge()
  15. setContentView(R.layout.activity_main)
  16. ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
  17. val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
  18. v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
  19. insets
  20. }
  21. var numb : Int
  22. numb = 0
  23. val btnChInc = findViewById<Button>(R.id.button4)
  24. val btnChDec = findViewById<Button>(R.id.button3)
  25. val btnChCl = findViewById<Button>(R.id.button2)
  26. val txtCh = findViewById<TextView>(R.id.textView)
  27. btnChInc.setOnClickListener {
  28. numb++
  29. txtCh.text = numb.toString()
  30. }
  31. btnChDec.setOnClickListener {
  32. numb--
  33. txtCh.text = numb.toString()
  34. }
  35. btnChCl.setOnClickListener {
  36. txtCh.text = "0"
  37. numb = 0
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment