Develop An Application To Show F
Develop An Application To Show F
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option 1"
android:textSize="16sp" />
<CheckBox
android:id="@+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option 2"
android:textSize="16sp"
android:layout_marginTop="8dp" />
<CheckBox
android:id="@+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option 3"
android:textSize="16sp"
android:layout_marginTop="8dp" />
<CheckBox
android:id="@+id/checkBox4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option 4"
android:textSize="16sp"
android:layout_marginTop="8dp" />
<CheckBox
android:id="@+id/checkBox5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option 5"
android:textSize="16sp"
android:layout_marginTop="8dp" />
<Button
android:id="@+id/submitButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Selected"
android:layout_marginTop="16dp" />
<TextView
android:layout_marginTop="25dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:textSize="15dp"/>
</LinearLayout>
package com.example.q6;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
checkBox1 = findViewById(R.id.checkBox1);
checkBox2 = findViewById(R.id.checkBox2);
checkBox3 = findViewById(R.id.checkBox3);
checkBox4 = findViewById(R.id.checkBox4);
checkBox5 = findViewById(R.id.checkBox5);
submitButton = findViewById(R.id.submitButton);
textView = findViewById(R.id.textView);
submitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String result= "";
if (checkBox1.isChecked())
result += checkBox1.getText().toString()+"\n";
if (checkBox2.isChecked())
result += checkBox2.getText().toString()+"\n";
if (checkBox3.isChecked())
result += checkBox3.getText().toString()+"\n";
if (checkBox4.isChecked())
result += checkBox4.getText().toString()+"\n";
if (checkBox5.isChecked())
result += checkBox5.getText().toString()+"\n";