Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Practical 11 Mad

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

<?xml version="1.0" encoding="utf-8"?

>

<AbsoluteLayout 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"

android:background="#E8EFEE"

tools:context=".MainActivity">

<CheckBox

android:id="@+id/check1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_x="130dp"

android:layout_y="106dp"

android:background="#ED6258"

android:padding="20sp"

android:text="PWP"

tools:layout_editor_absoluteX="140dp"

tools:layout_editor_absoluteY="107dp" />

<CheckBox

android:id="@+id/check2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_x="132dp"

android:layout_y="198dp"

android:background="#ED6258"

android:padding="20sp"

android:text="MAD"

tools:layout_editor_absoluteX="138dp"
tools:layout_editor_absoluteY="199dp" />

<CheckBox

android:id="@+id/check3"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_x="135dp"

android:layout_y="301dp"

android:background="#03A9F4"

android:padding="20sp"

android:text="PHP"

tools:layout_editor_absoluteX="140dp"

tools:layout_editor_absoluteY="288dp" />

<CheckBox

android:id="@+id/check4"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_x="135dp"

android:layout_y="409dp"

android:background="#4CAF50"

android:padding="20sp"

android:text="EDE"

tools:layout_editor_absoluteX="140dp"

tools:layout_editor_absoluteY="387dp" />

<CheckBox

android:id="@+id/check5"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_x="137dp"
android:layout_y="511dp"

android:background="#4CAF50"

android:padding="20sp"

android:text="ETI"

tools:layout_editor_absoluteX="150dp"

tools:layout_editor_absoluteY="492dp" />

<TextView

android:id="@+id/textView"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_x="83dp"

android:layout_y="46dp"

android:text="SELECT YOUR SUBJECT"

android:textColor="#3F51B5"

android:textSize="20sp" />

</AbsoluteLayout>

Java File

package com.example.checkbox;

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;

public class MainActivity extends AppCompatActivity {

CheckBox check1, check2, check3, check4, check5;

@SuppressLint("MissingInflatedId")

@Override

protected void onCreate(Bundle savedInstanceState) {


super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

check1 = (CheckBox) findViewById(R.id.check1);

check2 = (CheckBox) findViewById(R.id.check2);

check3 = (CheckBox) findViewById(R.id.check3);

check4 = (CheckBox) findViewById(R.id.check4);

check5 = (CheckBox) findViewById(R.id.check5);

check1.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

if (check1.isChecked()) {

String getCBData = check1.getText().toString();

Toast.makeText(MainActivity.this, "you selected PHP", Toast.LENGTH_SHORT).show();

} else {

String getCBData = check1.getText().toString();

Toast.makeText(MainActivity.this, "you Unchecked PHP",

Toast.LENGTH_SHORT).show();

});

check2.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

if (check2.isChecked()) {

String getCBData = check2.getText().toString();

Toast.makeText(MainActivity.this, "you selected MAD", Toast.LENGTH_SHORT).show();

} else {

String getCBData = check2.getText().toString();

Toast.makeText(MainActivity.this, "you Unchecked MAD",

Toast.LENGTH_SHORT).show();

}
}

});

check3.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

if (check3.isChecked()) {

String getCBData = check3.getText().toString();

Toast.makeText(MainActivity.this, "you selected PHP", Toast.LENGTH_SHORT).show();

} else {

String getCBData = check3.getText().toString();

Toast.makeText(MainActivity.this, "you Unchecked PHP",

Toast.LENGTH_SHORT).show();

}}

});

check4.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

if (check4.isChecked()) {

String getCBData = check4.getText().toString();

Toast.makeText(MainActivity.this, "you selected EDE", Toast.LENGTH_SHORT).show();

} else {

String getCBData = check4.getText().toString();

Toast.makeText(MainActivity.this, "you Unchecked EDE",

Toast.LENGTH_SHORT).show();

}}

});

check5.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

if (check5.isChecked()) {

String getCBData = check5.getText().toString();


Toast.makeText(MainActivity.this, "you selected ETI", Toast.LENGTH_SHORT).show();

} else {

String getCBData = check5.getText().toString();

Toast.makeText(MainActivity.this, "you Unchecked ETI", Toast.LENGTH_SHORT).show();

});}}

You might also like