Android how to used Checkbox

 Checkbox  in Android  

in this article, I am discussing how to use a checkbox in android. and how to get select checkbox value in string its very easy and simple format to use it.

Step 1:-  Create a project in android and create an activity.

Step 2:- Open your activity XML file and add checkbox code.

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
        <CheckBox
            android:id="@+id/radioOnline"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Online "
            />

        <CheckBox
            android:id="@+id/radioCash"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Cash" />

        <CheckBox
            android:id="@+id/radioCheck"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Cheque"
            />

        <CheckBox
            android:id="@+id/radioBalance"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Balance" />
</LinearLayout>

In these design, I am using four checkboxes you can use according to your requirements and implement these.

Step 3: Open your java file am implement these

public class CompleteCondition extends AppCompatActivity{

 CheckBox radioOnline,radioCash,radioCheck,radioBalance; 

  @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_complete_condition); 
    radioOnline=(CheckBox) findViewById(R.id.radioOnline);
    radioCash=(CheckBox) findViewById(R.id.radioCash);
    radioCheck=(CheckBox) findViewById(R.id.radioCheck);
    radioBalance=(CheckBox) findViewById(R.id.radioBalance);
    radioOnline.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

        }
    });
    radioCheck.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            

        }
    });
    radioCash.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            
        }
    });
    radioBalance.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

        }
    });

 } }

 

 

Facebooktwitterredditpinterestlinkedinmail
Recommended
  Android WebView Example Tutorial Android WebView is used to…