AndroidManifest.xml
MainActivity.java
import android.content.Intent;
import android.app.*;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
// nama kelas harus sama dengan nama file nya
public class MainActivity extends Activity {
Button bKirim;
RadioGroup radio;
EditText tNama;
EditText tHobi;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
inisialisasi();
bKirim.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View view) {
Intent i = new Intent(getApplicationContext(), second.class);
i.putExtra("variabelnama", tNama.getText().toString());
i.putExtra("variabelumur", tHobi.getText().toString());
int id = radio.getCheckedRadioButtonId();
RadioButton radiobutton = (RadioButton)findViewById(id);
i.putExtra("variabelkelamin", radiobutton.getText().toString());
startActivity(i);
}
});
}
private void inisialisasi() {
bKirim = (Button)findViewById(R.id.kirim);
radio = (RadioGroup)findViewById(R.id.jeniskelamin);
tNama = (EditText)findViewById(R.id.nama);
tHobi= (EditText)findViewById(R.id.hobi);
}
}
second.java
import android.content.Intent;
import android.app.*;
import android.os.Bundle;
import android.widget.TextView;
public class second extends Activity {
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.secondmain);
Intent i = getIntent();
String nerimanama = i.getStringExtra("variabelnama");
String nerimaumur = i.getStringExtra("variabelumur");
String kelamin = i.getStringExtra("variabelkelamin");
TextView nama = (TextView)findViewById(R.id.namaValue);
TextView umur = (TextView)findViewById(R.id.hobivalue);
TextView jk = (TextView)findViewById(R.id.jeniskelaminvalue);
nama.setText(nerimanama);
umur.setText(nerimaumur);
jk.setText(kelamin);
}
}