Berikut Source Code nya :
Main.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:ignore="HardcodedText" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/labelnim"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:text="Akbar Seto(A11.2011.05937)"
android:layout_centerHorizontal="true"
android:textSize="18sp" />
<TextView
android:id="@+id/labelnama"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/labelnim"
android:layout_marginTop="7dp"
android:text="Nama"
android:textSize="18sp" />
<EditText
android:id="@+id/fieldnama"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/labelnama"
android:layout_below="@+id/labelnim"
android:inputType="text" >
</EditText>
<TextView
android:id="@+id/labelemail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/labelnama"
android:layout_marginTop="15dp"
android:text="E-mail"
android:textSize="18sp" />
<EditText
android:id="@+id/fieldemail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/fieldnama"
android:layout_toRightOf="@+id/labelemail"
android:inputType="textEmailAddress" >
</EditText>
<TextView
android:id="@+id/labeljk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/labelemail"
android:layout_marginTop="15dp"
android:text="Jenis Kelamin"
android:textSize="18sp" />
<RadioGroup
android:id="@+id/groupjk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/labeljk"
android:orientation="horizontal"
android:padding="5dp" >
<RadioButton
android:id="@+id/radiolk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Laki-Laki"
android:textSize="18sp" />
<RadioButton
android:id="@+id/radiopr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Perempuan"
android:textSize="18sp" />
</RadioGroup>
<TextView
android:id="@+id/labelkeahlian"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/groupjk"
android:layout_marginTop="7dp"
android:text="Kegiatan"
android:textSize="18sp" />
<CheckBox
android:id="@+id/cekboxjava"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/labelkeahlian"
android:layout_marginTop="5dp"
android:text="Berenang"
android:textSize="18sp" />
<CheckBox
android:id="@+id/cekboxnet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cekboxjava"
android:layout_marginTop="5dp"
android:text="Futsal"
android:textSize="18sp" />
<CheckBox
android:id="@+id/cekboxsa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cekboxnet"
android:layout_marginTop="5dp"
android:text="Basket"
android:textSize="18sp" />
<Button
android:id="@+id/tomboltampil"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cekboxsa"
android:layout_marginTop="5dp"
android:text="TAMPILKAN"
android:textSize="18sp" />
<TextView
android:id="@+id/outputnama"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tomboltampil"
android:layout_marginTop="5dp"
android:textSize="18sp" />
<TextView
android:id="@+id/outputemail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/outputnama"
android:layout_marginTop="5dp"
android:textSize="18sp" />
<TextView
android:id="@+id/outputahli"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/outputemail"
android:layout_marginTop="5dp"
android:textSize="18sp" />
<TextView
android:id="@+id/outputjk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/outputahli"
android:layout_marginTop="5dp"
android:textSize="18sp" />
</RelativeLayout>
</ScrollView>
InputBiodataActivity.java
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.RadioGroup.OnCheckedChangeListener;
public class InputbiodataActivity extends Activity implements OnClickListener, OnCheckedChangeListener {
EditText fieldnama,fieldemail;
Button tomboltampil;
RadioGroup groupjk;
RadioButton radiolk, radiopr;
CheckBox cekboxrenang, cekboxbsket, cekboxftsal;
TextView outputnama, outputemail, outputjk, outputkgiatan;
String jk, kgiatan;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
fieldemail = (EditText)findViewById(R.id.fieldemail);
fieldnama = (EditText)findViewById(R.id.fieldnama);
tomboltampil = (Button)findViewById(R.id.tomboltampil);
groupjk = (RadioGroup)findViewById(R.id.groupjk);
cekboxrenang = (CheckBox)findViewById(R.id.cekboxjava);
cekboxbsket = (CheckBox)findViewById(R.id.cekboxsa);
cekboxftsal = (CheckBox)findViewById(R.id.cekboxnet);
outputnama =(TextView)findViewById(R.id.outputnama);
outputemail =(TextView)findViewById(R.id.outputemail);
outputkgiatan = (TextView)findViewById(R.id.outputahli);
outputjk = (TextView)findViewById(R.id.outputjk);
tomboltampil.setOnClickListener(this);
groupjk.setOnCheckedChangeListener(this);
}
@Override
public void onClick(View klik) {
// TODO Auto-generated method stub
outputnama.setText("Nama Anda : "+fieldnama.getText());
outputemail.setText("Email Anda : "+fieldemail.getText());
if (cekboxftsal.isChecked() && cekboxftsal.isChecked() && cekboxbsket.isChecked()){
outputkgiatan.setText("Kegiatan Anda : Berenang, Futsal & Basket");
}else if(cekboxrenang.isChecked() && cekboxftsal.isChecked()){
outputkgiatan.setText("Kegiatan Anda : Berenang & Futsal");
}else if(cekboxrenang.isChecked() && cekboxbsket.isChecked()){
outputkgiatan.setText("Kegiatan Anda : Berenang & Basket");
}else if(cekboxftsal.isChecked() && cekboxbsket.isChecked()){
outputkgiatan.setText("Kegiatan Anda : Futsal & Basket");
}else if(cekboxrenang.isChecked()){
outputkgiatan.setText("Kegiatan Anda : Berenang");
}else if(cekboxftsal.isChecked()){
outputkgiatan.setText("Kegiatan Anda : Futsal");
}else if(cekboxbsket.isChecked()){
outputkgiatan.setText("Kegiatan Anda : Basket");
}else{
outputkgiatan.setText("Kegiatan Anda : ");
}
outputjk.setText(jk);
fieldnama.setText("");
fieldemail.setText("");
cekboxrenang.setChecked(false);
cekboxbsket.setChecked(false);
cekboxftsal.setChecked(false);
groupjk.clearCheck();
}
@Override
public void onCheckedChanged(RadioGroup group, int check) {
// TODO Auto-generated method stub
if(check==R.id.radiolk){
jk="Jenis Kelamin : Laki-Laki";
}else if(check==R.id.radiopr){
jk="Jenis Kelamin : Perempuan";
}else{
jk="Jenis Kelamin :";
}
}
}
Hasil Input dan Outputnya
Tidak ada komentar:
Posting Komentar