Advertisement
hamidms

inikoding_toast_kotlin

Sep 24th, 2018
916
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.63 KB | None | 0 0
  1. package ik.inikoding.kotlin
  2.  
  3. import android.support.v7.app.AppCompatActivity
  4. import android.os.Bundle
  5. import android.widget.Button
  6. import android.widget.Toast
  7.  
  8. class MainActivity : AppCompatActivity() {
  9.  
  10.     override fun onCreate(savedInstanceState: Bundle?) {
  11.         super.onCreate(savedInstanceState)
  12.         setContentView(R.layout.activity_main)
  13.  
  14.         var button = findViewById(R.id.button_toast) as Button
  15.  
  16.         button.setOnClickListener {
  17.             // Pada saat tombol button ditekan, maka akan terbentuk Toast
  18.             Toast.makeText(this, "Halo, Selamat Pagi", Toast.LENGTH_SHORT).show()
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement