0% found this document useful (0 votes)
71 views4 pages

Source Code Apliaksi Quiz Sederhana

This document contains information about an Android application project created by M. Andrean Mahardika (NPM 1711010015) for an Advanced Mobile Programming practical exam at university. It includes the XML layout file and Java source code for an app that asks the user to select which football club won the 2020 UEFA Champions League, then displays a dialog if they answer correctly or a toast if incorrect. The full APK file is available at a Google Drive link.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views4 pages

Source Code Apliaksi Quiz Sederhana

This document contains information about an Android application project created by M. Andrean Mahardika (NPM 1711010015) for an Advanced Mobile Programming practical exam at university. It includes the XML layout file and Java source code for an app that asks the user to select which football club won the 2020 UEFA Champions League, then displays a dialog if they answer correctly or a toast if incorrect. The full APK file is available at a Google Drive link.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Nama : M.

Andrean Mahardika

NPM : 1711010015

UAS Praktikum Advanced Mobile Programming

Full Source Code

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;

public class MainActivity extends AppCompatActivity {


AlertDialog.Builder builder;
RadioGroup radiogroup;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
radiogroup = (RadioGroup) findViewById(R.id.radioGroup);
}

public void onRadioButton(View view) {

Boolean checked = ((RadioButton) view).isChecked();

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 = new AlertDialog.Builder(this);


builder.setCancelable(false);
builder.setTitle("Selamat !!!");
builder.setMessage("Jawaban kamu benar : FC Bayern München");
builder.setPositiveButton("OKE", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(MainActivity.this, "Selamat",
Toast.LENGTH_SHORT).show();
}
});

builder.setNegativeButton("ULANGI", new DialogInterface.OnClickListener() {


@Override
public void onClick(DialogInterface dialogInterface, int i) {
radiogroup.clearCheck();
}
});

builder.create().show();

public void jawabanSalah(){

Toast.makeText(this, "Jawaban kamu Salah", Toast.LENGTH_SHORT).show();

Apk file

https://drive.google.com/file/d/1G9Jff6nBEmqkSFR79hNP2LhxknHQ57vE/view?usp=sharing

You might also like