Instantly share code, notes, and snippets.

Embed
What would you like to do?
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