Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- btDetail.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String nama, npm, alamat, prodi, domisili;
- Boolean teknologi, kuliner;
- //definisikan nilai
- nama = etNama.getText().toString();
- npm = etNPM.getText().toString();
- alamat = etAlamat.getText().toString();
- prodi = spProdi.getSelectedItem().toString();
- teknologi = cbxTeknologi.isChecked();
- kuliner = cbxKuliner.isChecked();
- //konfirmasi
- if (nama.length() == 0 || npm.length() == 0 || alamat.length() == 0){
- Toast.makeText(getApplicationContext(),"Nama, NPM dan Alamat wajid diisi", Toast.LENGTH_SHORT).show();
- return;
- }
- /*
- triknya: pilih button group kemudian
- ambil radio button mana yang dipilih
- */
- int selectedId = rgDomisili.getCheckedRadioButtonId();
- rbDomisili = (RadioButton) findViewById(selectedId);
- domisili = rbDomisili.getText().toString(); //ambil hasil kelasnya
- /*
- Selipkan data yang ingin dikirim ke detail activity
- dengan putExtra
- */
- Intent i = new Intent(MainActivity.this, DetailActivity.class);
- i.putExtra("x_nama", nama);
- i.putExtra("x_npm", npm);
- i.putExtra("x_alamat", alamat);
- i.putExtra("x_prodi", prodi);
- i.putExtra("x_teknologi", teknologi); //boolean
- i.putExtra("x_kuliner", kuliner); //boolean
- i.putExtra("x_domisili", domisili);
- i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- getApplicationContext().startActivity(i);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement