You are on page 1of 2

XML File: Java File:

<?xml version="1.0" encoding="utf-8"?> package com.example.myapplication;


<LinearLayout import androidx.appcompat.app.AppCompatActivity;
xmlns:android="http://schemas. import android.os.Bundle;
android.com/apk/res/android" import android.view.View;
xmlns:app="http://schemas. import android.widget.Button;
android.com/apk/res-auto" import android.widget.CheckBox;
import android.widget.Toast;
xmlns:tools="http://schemas.android.com/t public class MainActivity extends AppCompatActivity {
ools" CheckBox c1;
android:layout_width="match_parent" CheckBox c2;
android:layout_height="match_parent" CheckBox c3;
tools:context=".MainActivity" CheckBox c4;
android:orientation="vertical"> CheckBox c5;
Button b1;
<CheckBox @Override
android:layout_width="wrap_content" protected void onCreate(Bundle savedInstanceState) {
android:layout_height="wrap_content" super.onCreate(savedInstanceState);
android:text="MAD" setContentView(R.layout.activity_main);
android:id="@+id/a"/> c1=(CheckBox) findViewById(R.id.a);
<CheckBox c2=(CheckBox) findViewById(R.id.b);
android:layout_width="wrap_content" c3=(CheckBox) findViewById(R.id.c);
android:layout_height="wrap_content" c4=(CheckBox) findViewById(R.id.d);
android:text="PWP" c5=(CheckBox) findViewById(R.id.e);
android:id="@+id/b"/> b1=(Button) findViewById(R.id.b1);
<CheckBox }
android:layout_width="wrap_content" public void show(View view)
android:layout_height="wrap_content" {
android:text="WBP" String s="You Selected:";
android:id="@+id/c"/> if(c1.isChecked()==true)
<CheckBox {
android:layout_width="wrap_content" s+="MAD";
android:layout_height="wrap_content" }
android:text="EDE" if(c2.isChecked()==true)
android:id="@+id/d"/> {
<CheckBox s+=",PWP";
android:layout_width="wrap_content" }
android:layout_height="wrap_content" if(c3.isChecked()==true)
android:text="ETI" {
android:id="@+id/e"/> s+=",WBP";
}
<Button if(c4.isChecked()==true)
android:layout_width="wrap_content" {
android:layout_height="wrap_content" s+=",ETI";
android:text="Show" }
android:id="@+id/b1" if(c5.isChecked()==true)
android:onClick="show"/> {
</LinearLayout> s+=",EDE";
}
Toast.makeText(getApplicationContext(),s,Toast.LENGTH_LONG).s
how();
}
}
Output:

You might also like