Android Checkbox Example

ANDROID FOR FRESHERS

Android Checkbox Example

Android Checkbox Example

Java Code(CheckBoxAct)

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.TextView;

public class CheckBoxAct extends Activity

{
CheckBox checked1,checked2,checked3;
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState)

{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_check_box);
checked1 = (CheckBox)findViewById(R.id.cb1);
checked2 = (CheckBox)findViewById(R.id.cb2);
checked3 = (CheckBox)findViewById(R.id.cb3);
tv = (TextView)findViewById(R.id.textView);
}
public void displayItems(View v)
{
String st1,st2,st3;
if(checked1.isChecked())
{
st1 = checked1.getText().toString();
}
else
{
st1=””;
}
if(checked2.isChecked())
{
st2 = checked2.getText().toString();
}
else
{
st2=””;
}
if(checked3.isChecked())
{
st3 = checked3.getText().toString();
}
else
{
st3=””;
}
tv.setText(st1+”\n”+st2+”\n”+st3);
}
}

 

Layout XML code(activity_check_box)

 <?xml version=”1.0″ encoding=”utf-8″?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
xmlns:tools=”http://schemas.android.com/tools”
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:orientation=”vertical”
android:paddingBottom=”@dimen/activity_vertical_margin”
android:paddingLeft=”@dimen/activity_horizontal_margin”
android:paddingRight=”@dimen/activity_horizontal_margin”
android:paddingTop=”@dimen/activity_vertical_margin”
tools:context=”com.andro.tech.androidproject.CheckBoxAct”>

<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:textSize=”@dimen/textsize”
android:textStyle=”bold”
android:layout_gravity=”center”
android:text=”@string/checkboxtext”
android:layout_marginBottom=”60dp” />

<CheckBox
android:layout_width=”100dp”
android:layout_height=”wrap_content”
android:id=”@+id/cb1″
android:layout_gravity=”center”
android:text=”C”
android:layout_marginBottom=”10dp”/>

<CheckBox
android:layout_width=”100dp”
android:layout_height=”wrap_content”
android:layout_gravity=”center”
android:id=”@+id/cb2″
android:text=”C++”
android:layout_marginBottom=”10dp” />

<CheckBox
android:layout_width=”100dp”
android:layout_height=”wrap_content”
android:id=”@+id/cb3″
android:layout_gravity=”center”
android:text=”Java”
android:layout_marginBottom=”20dp”/>

<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_gravity=”center”
android:textAppearance=”?
android:attr/textAppearanceLarge”
android:text=” “
android:id=”@+id/textView”
android:layout_marginBottom=”20dp” />

<Button
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”Submit”
android:layout_gravity=”center”
android:onClick=”displayItems”
android:id=”@+id/button”
android:layout_marginBottom=”60dp”/>

<Button
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/sourcecode”
android:background=”@color/bgcolor”
android:textStyle=”bold”
android:textColor=”@color/text”
android:onClick=”view1″/>

</LinearLayout>

 

Android Checkbox Example Output:

Android Checkbox source code download  Android Checkbox source code download

Android Checkbox source code download

Download CheckBox Source Code

For More Android Programs –Click Here

 

Follow Us – Never Miss Update

Fb/PageTwitterGoogle+InstagramPinterest

 

Related Search

Android Checkbox source code download, Android checkbox example code download, checkbox checked unchecked examples, checkbox android example source download, uncheck check source download android

Blaupunkt Announces New TVs: 32″ HD to 75″ 4K QLED TV | Offer Sales Xiaomi Pad 6 Coming to India: Unveiling Full Specs, Features & Pricing Redmi Buds 4 Active launching in India: Powerful Bass and Gaming Mode boAt Wave Neo Smartwatch | Features and Specs | Price: ₹ 1,499 OnePlus 11 5G Marble Odyssey on Sale: Flat Discount Offers Available