Uploaded by User93834

progres 6 quis

advertisement
Modul Pemrograman Mobile
1. Buat file baru dengan nama aplikasi “latihan_quis/bebas aja………”
2. Buat layout seperti contoh berikut di..(activity_main.XML)
3. Komponen yg diperlukan ;
- TextView
- RadioGroup
- RadioButton
- Button
4. Ketik baris perintah berikut di..(MainActivity.JAVA)..
import
import
import
import
import
import
import
android.support.v7.app.AppCompatActivity;
android.os.Bundle;
android.widget.Button;
android.widget.RadioButton;
android.widget.RadioGroup;
android.view.View;
android.widget.Toast;
public class MainActivity extends AppCompatActivity {
private Button jawab;
private RadioGroup list_jawaban;
private RadioButton lima, sepuluh, limabelas;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
list_jawaban = findViewById(R.id.list_jawaban);
lima = findViewById(R.id.lima);
sepuluh = findViewById(R.id.sepuluh);
limabelas = findViewById(R.id.limabelas);
jawab = findViewById(R.id.jawab);
jawab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
UserAnswer();
}
});
}
private void UserAnswer(){
if(lima.isChecked()){
Toast.makeText(getApplicationContext(),
Toast.LENGTH_SHORT).show();
}else if(sepuluh.isChecked()){
Toast.makeText(getApplicationContext(),
Toast.LENGTH_SHORT).show();
}else if(limabelas.isChecked()){
Toast.makeText(getApplicationContext(),
Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(getApplicationContext(),
Dipilih",
Toast.LENGTH_SHORT).show();
}
}
}
"SALAH",
"BENAR",
"SALAH",
"Tidak Ada Jawaban Yang
Download