Toast Using

MainActivity.java

package com.codewithahsan.dummyapp;


import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

public void send(View view) {
Toast.makeText(this, "Sending data from app...", Toast.LENGTH_SHORT).show();
}
public void receive(View view) {
Toast.makeText(this, "Receiving data from app...", Toast.LENGTH_SHORT).show();
}
public void delete(View view) {
Toast.makeText(this, "Deleting data from app...", Toast.LENGTH_SHORT).show();
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}

activity_main.xml
<?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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<ImageView
android:id="@+id/imageView3"
android:layout_width="249dp"
android:layout_height="250dp"
android:layout_marginTop="125dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@mipmap/ic_launcher_round" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:layout_marginLeft="50dp"
android:onClick="send"
android:text="@string/send_message"
app:layout_constraintBaseline_toBaselineOf="@+id/button2"
app:layout_constraintStart_toStartOf="parent" />

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="115dp"
android:onClick="receive"
android:text="@string/receive_message"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/button3"
app:layout_constraintHorizontal_bias="0.479"
app:layout_constraintStart_toEndOf="@+id/button"
app:layout_constraintTop_toBottomOf="@+id/imageView3"
app:layout_constraintVertical_bias="0.182" />

<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="50dp"
android:layout_marginRight="50dp"
android:onClick="delete"
android:text="@string/delete_message"
app:layout_constraintBaseline_toBaselineOf="@+id/button2"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

string.xml
<resources>
<string name="app_name">Dummy App</string>
<string name="send_message">Send</string>
<string name="receive_message">Receive</string>
<string name="delete_message">Delete</string>
</resources>




0 Comments

Brand creation, trend analysis & style consulting

Lorem Ipsum has been the industry's standard dummy text ever since. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since.