Skip to content

Instantly share code, notes, and snippets.

@code-crusher
Last active July 30, 2016 15:59
Show Gist options
  • Save code-crusher/3946d9852e5319e587887d012009dfd9 to your computer and use it in GitHub Desktop.
Save code-crusher/3946d9852e5319e587887d012009dfd9 to your computer and use it in GitHub Desktop.
Kotlin Demo
class KotlinActivity : AppCompatActivity() {
val text = "Made with Kotlin"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_kotlin)
init()
}
private fun init() {
val toolbar = findViewById(R.id.toolbar) as Toolbar?
setSupportActionBar(toolbar)
val fab = findViewById(R.id.fab) as FloatingActionButton?
fab!!.setOnClickListener { openRepo() }
}
private fun openRepo() {
val url = "https://github.com/code-crusher/KAndy"
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(url)
startActivity(i)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment