Alert tutorial.
First, your XML layout should include an id
for the ConstraintLayout
.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="@layout/activity_main">
</androidx.constraintlayout.widget.ConstraintLayout>
The critical part is the android:id="@+id/mainLayout"
. Don't forget it. It has an id
of mainLayout
.
Next, we need to write some Kotlin code. It's not too difficult, just type this:
Snackbar.make(mainLayout, "Updated 3h ago", Snackbar.LENGTH_INDEFINITE).show()
Alert tutorial.
Material Design.
Stroke it.
Create beautiful buttons in XML.
Built with Android Studio and Kotlin.
Getting started is sometimes the hardest part.
Add a click listener in Kotlin.
Let users sign in.
It always begins with registration.