0% found this document useful (0 votes)
19 views2 pages

To Do List Application With Toast: Mainactivity - Java

This document describes a to-do list Android application that uses a button to display a toast notification with the text "Packed" when clicked. The application contains a MainActivity class that extends AppCompatActivity and overrides the onCreate method to set the activity layout, find the button view by ID, and set an onClick listener on the button to call Toast.makeText to display the toast notification for a long duration when clicked.

Uploaded by

meena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

To Do List Application With Toast: Mainactivity - Java

This document describes a to-do list Android application that uses a button to display a toast notification with the text "Packed" when clicked. The application contains a MainActivity class that extends AppCompatActivity and overrides the onCreate method to set the activity layout, find the button view by ID, and set an onClick listener on the button to call Toast.makeText to display the toast notification for a long duration when clicked.

Uploaded by

meena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

To do list application with toast

MainActivity.java

package com.example.todolist;

import androidx.appcompat.app.AppCompatActivity;

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

public class MainActivity extends AppCompatActivity {

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

b= (Button)findViewById(R.id.btn);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainActivity.this,"Packed",Toast.LENGTH_LONG).show();
}
});
}

Design
To do list application with toast

output:

You might also like