fahad005

toast (kotlin)

Oct 26th, 2021
699
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.example.firstapplication
  2.  
  3. import androidx.appcompat.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.         // this part
  15.         val btn = findViewById<Button>(R.id.button)
  16.         btn.setOnClickListener{
  17.             Toast.makeText(this, "This is toast!", Toast.LENGTH_SHORT).show() // (activity, message, time)
  18.         }
  19.     }
  20. }
RAW Paste Data