Practical No 15
Practical No 15
Q.1}
XML File:-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World.Toast Example"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="show Toast"
android:onClick="Popup"/>
</LinearLayout>
Java:-
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void Popup(View view)
{
Toast.makeText(this,"Message for you\nYou have got
mail!",Toast.LENGTH_LONG).show();
}
}
Output:-
Q.2}
XML File:-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pizza"
android:id="@+id/p"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Coffe"
android:id="@+id/c"/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Burger"
android:id="@+id/b"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="order"
android:onClick="order"/>
</LinearLayout>
Java:-
package com.example.a15_2;
import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.Toast;