Skip to content

Instantly share code, notes, and snippets.

@ssaurel
Created April 25, 2018 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssaurel/b8ba82920c48d03d24fb3e59c0ac55bc to your computer and use it in GitHub Desktop.
Save ssaurel/b8ba82920c48d03d24fb3e59c0ac55bc to your computer and use it in GitHub Desktop.
Kotlin Code of the Main Activity for the Counter App Tutorial on the SSaurel's Blog
package com.ssaurel.kotlincounter
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
var id = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
value.setText("" + id)
plusBtn.setOnClickListener {
value.setText("" + ++id)
}
minusBtn.setOnClickListener {
value.setText("" + --id)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment