Advertisement
fahad005

toast (kotlin)

Oct 26th, 2021
846
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.59 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement