source code untuk actifitymain "a.xml"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Alfandy pratam kasim"
android:textAppearance="?android:attr/textAppearanceLarge" />
<CheckBox
android:id="@+id/c1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Java" />
<CheckBox
android:id="@+id/c2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PHP" />
<CheckBox
android:id="@+id/c3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Android" />
<Button
android:id="@+id/b1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<TextView
android:id="@+id/tampilan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
tampilanya.
----------------------------------------------------------------------------------------------------------------------------
public class MainActivity extends Activity implements OnClickListener {
CheckBox j,p,a;
Button t;
TextView o;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.a);
j=(CheckBox)findViewById(R.id.c1);
p=(CheckBox)findViewById(R.id.c2);
a=(CheckBox)findViewById(R.id.c3);
t=(Button)findViewById(R.id.b1);
o=(TextView)findViewById(R.id.tampilan);
t.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (j.isChecked() && p.isChecked()
&& a.isChecked()) {
o.setText("pilihan anda adalah :JAVA,PHP,ANDROID");
}else if(j.isChecked()&& p.isChecked()){
o.setText("pilihan anda adalah :JAVA,PHP");
}else if(j.isChecked()&& a.isChecked()){
o.setText("pilihan anda adalah :JAVA,ANDROID");
}else if(a.isChecked()&& p.isChecked()){
o.setText("pilihan anda adalah :PHP,ANDROID");
}else if(a.isChecked()){
o.setText("pilihan anda adalah :ANDROID");
}else if(p.isChecked()){
o.setText("pilihan anda adalah :PHP");
}else if(j.isChecked()){
o.setText("pilihan anda adalah :JAVA");
}else {
o.setText("ngana ini hobi tidak ba pilih");
}
j.setChecked(false);
p.setChecked(false);
a.setChecked(false);
}
}
hasil raning.