Experiment No4
Experiment No4
Aim:
Problem Statement:
Create a simple Android application that demonstrates the use of “Toast messages”.
The app should allow the user to interact with buttons, and when a button is clicked, a toast
message should be displayed.
The app should have a main screen with a Plain Text and button
Source Code
MainActivity.java
package com.example.toast;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
}
});
}
}
activity_main.xml
<EditText
android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:hint="enter your message"
android:inputType="text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.157" />
<Button
android:id="@+id/b1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="send"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
RESULT