Source Code Apliaksi Quiz Sederhana
Source Code Apliaksi Quiz Sederhana
Andrean Mahardika
NPM : 1711010015
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/activity_main"
android:padding="15dp">
<TextView
android:text="Club sepak bola yang memenangkan liga champions 2020 adalah :"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:textSize="25sp"
android:textColor="@android:color/black"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:textStyle="bold"/>
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true"
android:layout_marginTop="39dp"
android:id="@+id/radioGroup" >
<RadioButton
android:text="Real Madrid"
android:foreground="?attr/selectableItemBackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/radioButton"
android:onClick="onRadioButton"
android:layout_toLeftOf="@+id/radioGroup"
android:layout_toStartOf="@+id/radioGroup"
android:layout_below="@+id/radioGroup"/>
<RadioButton
android:text="Liverpool"
android:foreground="?attr/selectableItemBackground"
android:onClick="onRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/radioButton"
android:layout_alignLeft="@+id/radioButton"
android:layout_alignStart="@+id/radioButton"
android:layout_marginTop="36dp"
android:id="@+id/radioButton2"/>
<RadioButton
android:text="FC Bayern München"
android:foreground="?attr/selectableItemBackground"
android:onClick="onRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="26dp"
android:id="@+id/radioButton3"
android:layout_below="@+id/radioButton2"
android:layout_alignLeft="@+id/radioButton2"
android:layout_alignStart="@+id/radioButton2"/>
<RadioButton
android:text="PSG"
android:foreground="?attr/selectableItemBackground"
android:onClick="onRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/radioButton3"
android:layout_alignLeft="@+id/radioButton3"
android:layout_alignStart="@+id/radioButton3"
android:layout_marginTop="39dp"
android:id="@+id/radioButton4"/>
</RadioGroup>
</RelativeLayout>
Main_activity.java
package com.mandreanmahardika_1711010015.aplikasiuts;
import android.content.DialogInterface;
import android.os.Bundle;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AlertDialog;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
radiogroup = (RadioGroup) findViewById(R.id.radioGroup);
}
switch (view.getId()) {
case R.id.radioButton:
if (checked)
jawabanSalah();
break;
case R.id.radioButton2:
if (checked)
jawabanSalah();
break;
case R.id.radioButton3:
if (checked)
tampilDialog();
break;
case R.id.radioButton4:
if (checked)
jawabanSalah();
break;
}
}
public void tampilDialog() {
builder.create().show();
Apk file
https://drive.google.com/file/d/1G9Jff6nBEmqkSFR79hNP2LhxknHQ57vE/view?usp=sharing