Simple example of Button and Toast (Android Kotlin)

Simple example of Button and Toast (Android Kotlin)

exercise_major.xml




    

        

MainActivity.kt

package android_er.blogspot.com.myapp01

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.perspective.See
import android.widget.Button
import android.widget.Toast

private lateinit var btnA: Button
personal lateinit var btnB: Button

course MainActivity : AppCompatActivity() 
    override fun onCreate(savedInstanceState: Bundle?) 
        tremendous.onCreate(savedInstanceState)
        setContentView(R.format.action_most important)

        btnA = findViewById(R.id.btn_A)
        btnB = findViewById(R.id.btn_B)

        btnA.setOnClickListener(
             view: See ->
                Toast.makeText(
                    this,
                    "Button A pressed",
                    Toast.Size_Extended,
                ).display()
            ,
        )

        btnB.setOnClickListener(
             watch: Perspective ->
                Toast.makeText(
                    this,
                    "Button B pressed",
                    Toast.Size_Extensive,
                ).present()
            ,
        )
    

Next Post

It’s Time to Sell on Social

Advertising merchandise on social media normally enhanced through the pandemic because several shoppers only did not have a option. But the extended months of lockdown and the growing buying electric power of young, social media-loving generations has made a lasting appetite for social offering. People are not obtaining on social […]
It’s Time to Sell on Social

You May Like