Snackbars
deliver lightweight feed-back about an operation. They exhibit a quick concept
at the base of the monitor on cellular and decrease still left on bigger gadgets.
Snackbars surface over all other aspects on monitor and only a single can be
shown at a time.
They quickly vanish following a timeout
or after person conversation somewhere else on the monitor, significantly right after
interactions that summon a new floor or action. Snackbars can be swiped
off display.
It really is a most basic case in point to show Snackbar applying Kotlin. The
format xml is very same as past put up “Very simple case in point of Button and Toast”.
MainActivity.kt
bundle android_er.blogspot.com.myapp01
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.Toast
import androidx.appcompat.application.AppCompatActivity
import com.google.android.materials.snackbar.Snackbar
non-public lateinit var btnA: Button
personal lateinit var btnB: Button
course MainActivity : AppCompatActivity()
override pleasurable onCreate(savedInstanceState: Bundle?)
super.onCreate(savedInstanceState)
setContentView(R.format.activity_key)
btnA = findViewById(R.id.btn_A)
btnB = findViewById(R.id.btn_B)
btnA.setOnClickListener(
look at: See ->
Toast.makeText(
this,
"Button A pressed",
Toast.Duration_Prolonged,
).display()
,
)
btnB.setOnClickListener(
see: Check out ->
val snackbar = Snackbar
.make(btnB,
"android-er.blogspot.com",
Snackbar.Length_Lengthy)
snackbar.show()
,
)
More Stories
Natural Tactics to Overcome Depression Without Medication
Celebrating Milestones Forward Can Yield Amazing Results
Radar Trends to Watch: July 2022 – O’Reilly