Android-er: Simplest Snackbar

Snackbars
provide light-weight responses about an operation. They present a quick message
at the base of the display on cell and decrease left on much larger equipment.
Snackbars appear earlier mentioned all other features on monitor and only 1 can be
shown at a time.

They automatically vanish after a timeout
or following consumer interaction somewhere else on the display screen, specially just after
interactions that summon a new floor or action. Snackbars can be swiped
off display screen.

It can be a easiest illustration to show Snackbar applying Kotlin. The
layout xml is similar as previous submit “Straightforward illustration of Button and Toast”.

Android-er: Simplest Snackbar

MainActivity.kt

deal android_er.blogspot.com.myapp01

import android.os.Bundle
import android.look at.View
import android.widget.Button
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.google.android.materials.snackbar.Snackbar

non-public lateinit var btnA: Button
private lateinit var btnB: Button

course MainActivity : AppCompatActivity() 
    override pleasurable onCreate(savedInstanceState: Bundle?) 
        tremendous.onCreate(savedInstanceState)
        setContentView(R.structure.exercise_key)

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

        btnA.setOnClickListener(
             view: See ->
                Toast.makeText(
                    this,
                    "Button A pressed",
                    Toast.Duration_Long,
                ).clearly show()
            ,
        )

        btnB.setOnClickListener(
             see: See ->
                val snackbar = Snackbar
                    .make(btnB,
                        "android-er.blogspot.com",
                        Snackbar.Duration_Extensive)
                snackbar.demonstrate()
            ,
        )
    

Next Post

NFT's and Crypto in eCommerce

Table of Contents: What is Web 3.0?What are Cryptocurrencies?What are Non-Fungible Tokens (NFTs)?What Web 3.0 Means for MarketersEnhanced User PrivacyUsing NFTs as a Marketing ToolA Tale of Two InternetsPosturing Your Marketing for the Future Web 3.0. Cryptocurrency. Non-Fungible Tokens… These three buzz words dominated popular culture throughout 2021, and they […]
NFT’s and Crypto in eCommerce

You May Like