How To Use Android Checkbox In Android App

In Android Checkbox Is Simply Use For the Selection. When We Want To Choose More Than One Item Then We Have To Use This Control.

 

 

Checkbox

  • We can create this  instance by declaring it inside a layout(XML file) or by instantiating it programmatically(Java Class).

Activity_main.xml:

 code in JAVA:

Step 1: Create a new project and name it What You Want TO Give.

  • Select File -> New -> New Project. Fill the forms and click “Finish” button.

Step 2: Open res -> layout -> xml (or) activity_main.xml and add following code. Here we will create a CheckBox in Relative Layout

Step 3: Open app -> java -> package and open MainActivity.java and add the following code. Here we will display in toast which is checked.

Output :

Now run the app in Emulator and click on the button. You will see which checkbox is checked and display it name in toast.

Checkbox

Leave a Reply

Your email address will not be published. Required fields are marked *