Pada kesempatan kali ini saya mencoba membuat aplikasi ujian berbasis android. Aplikasi ini saya buat sebagai pengumpulan tugas Ujian Akhir Semester untuk mata kuliah Mobile Programming.
Aplikasi ujian online ini adalah aplikasi yang bertujuan untuk mempermudah melakukan ujian, yaitu secara online. Dengan adanya aplikasi ini diharapkan dapat mempermudah pengguna untuk melakukan ujian secara online dan tidak perlu menggunakan alat tulis untuk melakukan pengerjaan. Aplikasi ini saya buat dengan menggunakan Eclipse dan melakukan running aplikasi langsung menggunakan ponsel.
- Membuat file Android Project Baru dengan nama Rosya_161011400074
- Membuat Activity besrta file Java-nya, diantaranya :
- activity_main (login form),
- activity_welcome (berhasil login),
- activity_uts (soal ujian),
- activity_ujian_selesai (cetak nilai)
Berikut ini saya sertakan detail xml graphic dan source code .xml beserta source code .java
- activity_main.xml
<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"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true">
<TextView
android:text="Silahkan Login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="27dp"
android:id="@+id/textView"
android:textAlignment="center"
android:gravity="center"
android:textSize="30sp"
android:textStyle="normal|bold"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/username"
android:hint="Username"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="157dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:layout_below="@+id/username"
android:layout_alignParentLeft="true"
android:id="@+id/password"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:hint="Password" />
<Button
android:text="Log In"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/password"
android:layout_centerHorizontal="true"
android:id="@+id/btnLogin" />
</RelativeLayout>
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true">
<TextView
android:text="Silahkan Login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="27dp"
android:id="@+id/textView"
android:textAlignment="center"
android:gravity="center"
android:textSize="30sp"
android:textStyle="normal|bold"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/username"
android:hint="Username"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="157dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:layout_below="@+id/username"
android:layout_alignParentLeft="true"
android:id="@+id/password"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:hint="Password" />
<Button
android:text="Log In"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/password"
android:layout_centerHorizontal="true"
android:id="@+id/btnLogin" />
</RelativeLayout>
Berikut ini design layout dari activity_main.xml
- activity_welcome.xml
<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"
tools:context=".Welcome" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true">
<TextView
android:text="Selamat Datang"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="27dp"
android:id="@+id/textView"
android:textAlignment="center"
android:gravity="center"
android:textSize="30sp"
android:textStyle="normal|bold"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<TextView
android:text="Ujian Akhir Semester"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView4"
android:layout_below="@+id/textView3"
android:textAlignment="center"
android:gravity="center"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="70dp"
android:textSize="18sp" />
<TextView
android:text="Silahkan tekan tombol MULAI untuk mulai Ujian."
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView4"
android:layout_below="@+id/textView3"
android:textAlignment="center"
android:gravity="center"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="170dp"
android:textSize="18sp" />
<TextView
android:text="Selamat Mengerjakan !!!"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="normal|bold"
android:id="@+id/textView4"
android:layout_below="@+id/textView3"
android:textAlignment="center"
android:gravity="center"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="300dp"
android:textSize="18sp" />
<Button
android:id="@+id/btnMulai"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="410dp"
android:text="MULAI" >
</Button>
</RelativeLayout>
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Welcome" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true">
<TextView
android:text="Selamat Datang"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="27dp"
android:id="@+id/textView"
android:textAlignment="center"
android:gravity="center"
android:textSize="30sp"
android:textStyle="normal|bold"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<TextView
android:text="Ujian Akhir Semester"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView4"
android:layout_below="@+id/textView3"
android:textAlignment="center"
android:gravity="center"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="70dp"
android:textSize="18sp" />
<TextView
android:text="Silahkan tekan tombol MULAI untuk mulai Ujian."
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView4"
android:layout_below="@+id/textView3"
android:textAlignment="center"
android:gravity="center"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="170dp"
android:textSize="18sp" />
<TextView
android:text="Selamat Mengerjakan !!!"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="normal|bold"
android:id="@+id/textView4"
android:layout_below="@+id/textView3"
android:textAlignment="center"
android:gravity="center"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="300dp"
android:textSize="18sp" />
<Button
android:id="@+id/btnMulai"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="410dp"
android:text="MULAI" >
</Button>
</RelativeLayout>
Berikut ini design layout dari activity_welcome.xml
- activity_pilih_soal.xml
<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"
tools:context=".PilihSoal" >
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="28dp"
android:layout_marginTop="48dp" >
</ListView>
</RelativeLayout>
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PilihSoal" >
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="28dp"
android:layout_marginTop="48dp" >
</ListView>
</RelativeLayout>
Berikut ini design layout dari activity_pilih_soal.xml
- activity_mobile_programming.xml
<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"
tools:context=".MobileProgramming" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="TextView"
android:textSize="18sp" />
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_marginTop="60dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radio2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radio3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
</RadioGroup>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kembali"
/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Selanjutnya"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/button3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="380dp"
android:text="Selesai" />
</LinearLayout>
</RelativeLayout>
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MobileProgramming" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="TextView"
android:textSize="18sp" />
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_marginTop="60dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radio2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/radio3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
</RadioGroup>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kembali"
/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Selanjutnya"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/button3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="380dp"
android:text="Selesai" />
</LinearLayout>
</RelativeLayout>
Berikut ini design layout dari activity_mobile_programming.xml
- activity_ujian_selesai.xml
<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"
tools:context=".UjianSelesai" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="70dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="400dp"
android:text="Keluar" />
</RelativeLayout>
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".UjianSelesai" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="70dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="400dp"
android:text="Keluar" />
</RelativeLayout>
Berikut ini design layout dari activity_ujian_selesai.xml
- MainActivity.java
package com.uas.rosya_161011400074;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
//public class MainActivity extends Activity {
public class MainActivity extends Activity {
EditText username, password;
Button btnLogin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
username = (EditText) findViewById(R.id.username);
password = (EditText) findViewById(R.id.password);
btnLogin = (Button)findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String usernameKey = username.getText().toString();
String passwordKey = password.getText().toString();
if (usernameKey.equals("rosya") && passwordKey.equals("400074")){
//jika login berhasil
Toast.makeText(getApplicationContext(), "LOGIN SUKSES",
Toast.LENGTH_SHORT).show();
Intent intent = new Intent(MainActivity.this, Welcome.class);
MainActivity.this.startActivity(intent);
finish();
}else {
//jika login gagal
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage("Username atau Password Anda salah!")
.setNegativeButton("Retry", null).create().show();
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
//public class MainActivity extends Activity {
public class MainActivity extends Activity {
EditText username, password;
Button btnLogin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
username = (EditText) findViewById(R.id.username);
password = (EditText) findViewById(R.id.password);
btnLogin = (Button)findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String usernameKey = username.getText().toString();
String passwordKey = password.getText().toString();
if (usernameKey.equals("rosya") && passwordKey.equals("400074")){
//jika login berhasil
Toast.makeText(getApplicationContext(), "LOGIN SUKSES",
Toast.LENGTH_SHORT).show();
Intent intent = new Intent(MainActivity.this, Welcome.class);
MainActivity.this.startActivity(intent);
finish();
}else {
//jika login gagal
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage("Username atau Password Anda salah!")
.setNegativeButton("Retry", null).create().show();
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
Berikut ini hasil runing dari MainActivity.java
- Welcome.java
package com.uas.rosya_161011400074;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Welcome extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
Button btnMulai=(Button)findViewById(R.id.btnMulai);
//CQuiz=(Button)findViewById(R.id.button2);
btnMulai.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(Welcome.this, PilihSoal.class);
startActivity(intent);
finish();
}
});
}
}
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Welcome extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_welcome);
Button btnMulai=(Button)findViewById(R.id.btnMulai);
//CQuiz=(Button)findViewById(R.id.button2);
btnMulai.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(Welcome.this, PilihSoal.class);
startActivity(intent);
finish();
}
});
}
}
Berikut ini hasil runing dari Welcome.java
- PilihSoal.java
package com.uas.rosya_161011400074;
import com.uas.rosya_161011400074.PilihSoal;
import com.uas.rosya_161011400074.R;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class PilihSoal extends Activity {
ListView LV;
String [] Menu = {"Mobile Programming", "Grafika Komputer", "Pemograman I", "Basis Data"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pilih_soal);
LV=(ListView)findViewById(R.id.listView1);
ArrayAdapter adapter=new ArrayAdapter(this,android.R.layout.simple_list_item_single_choice,Menu);
LV.setAdapter(adapter);
LV.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int itemKe,
long arg3) {
// TODO Auto-generated method stub
String itemText=(String) LV.getItemAtPosition(itemKe);
Toast.makeText(getBaseContext(), "Anda Meng Klik " +itemText, Toast.LENGTH_LONG).show();
if(itemText.equals("Mobile Programming")){
Intent MobileInten=new Intent (arg0.getContext(),MobileProgramming.class);
startActivityForResult(MobileInten, 0);
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_pilih_soal, menu);
return true;
}
}
import com.uas.rosya_161011400074.PilihSoal;
import com.uas.rosya_161011400074.R;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class PilihSoal extends Activity {
ListView LV;
String [] Menu = {"Mobile Programming", "Grafika Komputer", "Pemograman I", "Basis Data"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pilih_soal);
LV=(ListView)findViewById(R.id.listView1);
ArrayAdapter adapter=new ArrayAdapter(this,android.R.layout.simple_list_item_single_choice,Menu);
LV.setAdapter(adapter);
LV.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int itemKe,
long arg3) {
// TODO Auto-generated method stub
String itemText=(String) LV.getItemAtPosition(itemKe);
Toast.makeText(getBaseContext(), "Anda Meng Klik " +itemText, Toast.LENGTH_LONG).show();
if(itemText.equals("Mobile Programming")){
Intent MobileInten=new Intent (arg0.getContext(),MobileProgramming.class);
startActivityForResult(MobileInten, 0);
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_pilih_soal, menu);
return true;
}
}
Berikut ini hasil runing dari PilihSoal.java
- MobileProgramming.java
package com.uas.rosya_161011400074;
import android.os.Bundle;
import android.app.Activity;
import java.util.ArrayList;
import java.util.HashMap;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;
public class MobileProgramming extends Activity {
Button selanjutnya,kembali,selesai;
RadioGroup rg;
RadioButton rb1,rb2,rb3,rb4;
TextView setque;
int index=0;
String MyCAns,UserCAns="";
int totalCurrect,totalQues=10,totalSkeep,totalWrrong;
ArrayList<HashMap<String, String>> MyArrList = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mobile_programming);
kembali=(Button)findViewById(R.id.button1);
selanjutnya=(Button)findViewById(R.id.button2);
selesai=(Button)findViewById(R.id.button3);
rg=(RadioGroup)findViewById(R.id.radioGroup1);
rb1=(RadioButton)findViewById(R.id.radio0);
rb2=(RadioButton)findViewById(R.id.radio1);
rb3=(RadioButton)findViewById(R.id.radio2);
rb4=(RadioButton)findViewById(R.id.radio3);
rb1.setChecked(false);
rb2.setChecked(false);
rb3.setChecked(false);
rb4.setChecked(false);
setque=(TextView)findViewById(R.id.textView1);
kembali.setVisibility(View.GONE);
selesai.setVisibility(View.GONE);
set_Your_Ques();
set_Ques_One();
rg.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
RadioButton rb=(RadioButton)findViewById(checkedId) ;
UserCAns=rb.getText().toString().trim();
}
});
kembali.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(UserCAns.equals("")){
totalSkeep++;
}else if(UserCAns.equals(MyCAns)){
totalCurrect++;
}else{
totalWrrong++;
}
UserCAns="";
rb1.setChecked(false);
rb2.setChecked(false);
rb3.setChecked(false);
rb4.setChecked(false);
back();
}
});
selanjutnya.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
kembali.setVisibility(View.VISIBLE);
if(UserCAns.equals("")){
totalSkeep++;
}else if(UserCAns.equals(MyCAns)){
totalCurrect++;
}else{
totalWrrong++;
}
UserCAns="";
rb1.setChecked(false);
rb2.setChecked(false);
rb3.setChecked(false);
rb4.setChecked(false);
next();
}
});
selesai.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(MobileProgramming.this, UjianSelesai.class);
intent.putExtra("totalquestion", "Total Pertanyaan : "+totalQues);
intent.putExtra("totalcurrect", "Total Nilai : "+totalCurrect);
intent.putExtra("totalSkeep", "Total Dilewati : "+totalSkeep);
intent.putExtra("totalWrrong", "Total Salah : "+totalWrrong);
startActivity(intent);
finish();
}
});
}
private void set_Ques_One() {
map=MyArrList.get(index);
setque.setText(map.get("Ques").toString().trim());
rb1.setText(map.get("A1").toString().trim());
rb2.setText(map.get("A2").toString().trim());
rb3.setText(map.get("A3").toString().trim());
rb4.setText(map.get("A4").toString().trim());
MyCAns=map.get("CA1").toString().trim();
//Toast.makeText(getApplicationContext(),"1"+index,2000).show();
}
public void next() {
if(index==9){
// kembali.setVisibility(View.GONE);
// selanjutnya.setVisibility(View.GONE);
kembali.setVisibility(View.VISIBLE);
selanjutnya.setVisibility(View.GONE);
selesai.setVisibility(View.VISIBLE);
}else{
index++;
//Toast.makeText(getApplicationContext(),""+index,2000).show();
map=MyArrList.get(index);
setque.setText(map.get("Ques").toString().trim());
rb1.setText(map.get("A1").toString().trim());
rb2.setText(map.get("A2").toString().trim());
rb3.setText(map.get("A3").toString().trim());
rb4.setText(map.get("A4").toString().trim());
MyCAns=map.get("CA1").toString().trim();
}
}
public void back() {
if(index==0){
kembali.setVisibility(View.GONE);
selanjutnya.setVisibility(View.VISIBLE);
selesai.setVisibility(View.GONE);
}else{
index--;
map=MyArrList.get(index);
setque.setText(map.get("Ques").toString().trim());
rb1.setText(map.get("A1").toString().trim());
rb2.setText(map.get("A2").toString().trim());
rb3.setText(map.get("A3").toString().trim());
rb4.setText(map.get("A4").toString().trim());
MyCAns=map.get("CA1").toString().trim();
}
}
public void set_Your_Ques() {
//Q 1
map=new HashMap<String, String>();
map.put("Ques", "MP1. Method yang digunakan untuk mengkonversi nilai string ke integer dalam Java adalah ?");
map.put("A1", "parseInt()");
map.put("A2", "converseInt()");
map.put("A3", "Cint()");
map.put("A4", "ChangeInt()");
map.put("CA1","parseInt()");
MyArrList.add(map);
//Q 2
map=new HashMap<String, String>();
map.put("Ques", "MP2. Software yang digunakan dalam pengembangan Android adalah ?");
map.put("A1", "Android Studio");
map.put("A2", "Androi Virtual Device Manager");
map.put("A3", "Standart Development Kit Manager");
map.put("A4", "Semua jawaban benar");
map.put("CA1","Semua jawaban benar");
MyArrList.add(map);
//Q 3
map=new HashMap<String, String>();
map.put("Ques", "MP3. Bahasa pemrograman android berbasis ?");
map.put("A1", "Java");
map.put("A2", "PHP");
map.put("A3", "C++");
map.put("A4", "Semua jawaban benar");
map.put("CA1","Java");
MyArrList.add(map);
//Q 4
map=new HashMap<String, String>();
map.put("Ques", "MP4. Android tidak bisa dikembangkan pada komputer dengan sistem operasi ?");
map.put("A1", "Windows XP");
map.put("A2", "DOS");
map.put("A3", "Red Hat");
map.put("A4", "Semua jawaban benar");
map.put("CA1","DOS");
MyArrList.add(map);
//Q 5
map=new HashMap<String, String>();
map.put("Ques", "MP5. Contoh brainware adalah ?");
map.put("A1", "Programmer");
map.put("A2", "Laptop");
map.put("A3", "Android Studio");
map.put("A4", "Semua jawaban benar");
map.put("CA1","Programmer");
MyArrList.add(map);
//Q6
map=new HashMap<String, String>();
map.put("Ques", "MP6. Pemilik dari Android saat ini adalah ?");
map.put("A1", "Android inc.");
map.put("A2", "Google inc.");
map.put("A3", "HTC");
map.put("A4", "Semua jawaban benar");
map.put("CA1","Google inc.");
MyArrList.add(map);
//Q7
map=new HashMap<String, String>();
map.put("Ques", "MP7. Berikut ini adalah keyword yang terdapat dalam Java, kecuali ?");
map.put("A1", "Goto");
map.put("A2", "Break");
map.put("A3", "If");
map.put("A4", "String");
map.put("CA1","String");
MyArrList.add(map);
//Q8
map=new HashMap<String, String>();
map.put("Ques", "MP8. Komentar program dalam java dapat menggunakan perintah ?");
map.put("A1", "/*...*/ saja");
map.put("A2", "// saja");
map.put("A3", "// dan /*...*/");
map.put("A4", "#, // dan /*...*/");
map.put("CA1","// dan /*...*/");
MyArrList.add(map);
//Q9
map=new HashMap<String, String>();
map.put("Ques", "MP9. Berikut ini adalah hak akses yang dapat ditambahkan didepan method Java, kecuali ?");
map.put("A1", "Static");
map.put("A2", "Public");
map.put("A3", "Private");
map.put("A4", "Protected");
map.put("CA1","Static");
MyArrList.add(map);
//Q10
map=new HashMap<String, String>();
map.put("Ques", "MP10. Method yang digunakan untuk mengubah panjang data StringBuffer adalah ?");
map.put("A1", "length()");
map.put("A2", "setLength()");
map.put("A3", "Changelength()");
map.put("A4", "reverse()");
map.put("CA1","setLength()");
MyArrList.add(map);
}
}
import android.os.Bundle;
import android.app.Activity;
import java.util.ArrayList;
import java.util.HashMap;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;
public class MobileProgramming extends Activity {
Button selanjutnya,kembali,selesai;
RadioGroup rg;
RadioButton rb1,rb2,rb3,rb4;
TextView setque;
int index=0;
String MyCAns,UserCAns="";
int totalCurrect,totalQues=10,totalSkeep,totalWrrong;
ArrayList<HashMap<String, String>> MyArrList = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mobile_programming);
kembali=(Button)findViewById(R.id.button1);
selanjutnya=(Button)findViewById(R.id.button2);
selesai=(Button)findViewById(R.id.button3);
rg=(RadioGroup)findViewById(R.id.radioGroup1);
rb1=(RadioButton)findViewById(R.id.radio0);
rb2=(RadioButton)findViewById(R.id.radio1);
rb3=(RadioButton)findViewById(R.id.radio2);
rb4=(RadioButton)findViewById(R.id.radio3);
rb1.setChecked(false);
rb2.setChecked(false);
rb3.setChecked(false);
rb4.setChecked(false);
setque=(TextView)findViewById(R.id.textView1);
kembali.setVisibility(View.GONE);
selesai.setVisibility(View.GONE);
set_Your_Ques();
set_Ques_One();
rg.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
RadioButton rb=(RadioButton)findViewById(checkedId) ;
UserCAns=rb.getText().toString().trim();
}
});
kembali.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(UserCAns.equals("")){
totalSkeep++;
}else if(UserCAns.equals(MyCAns)){
totalCurrect++;
}else{
totalWrrong++;
}
UserCAns="";
rb1.setChecked(false);
rb2.setChecked(false);
rb3.setChecked(false);
rb4.setChecked(false);
back();
}
});
selanjutnya.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
kembali.setVisibility(View.VISIBLE);
if(UserCAns.equals("")){
totalSkeep++;
}else if(UserCAns.equals(MyCAns)){
totalCurrect++;
}else{
totalWrrong++;
}
UserCAns="";
rb1.setChecked(false);
rb2.setChecked(false);
rb3.setChecked(false);
rb4.setChecked(false);
next();
}
});
selesai.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(MobileProgramming.this, UjianSelesai.class);
intent.putExtra("totalquestion", "Total Pertanyaan : "+totalQues);
intent.putExtra("totalcurrect", "Total Nilai : "+totalCurrect);
intent.putExtra("totalSkeep", "Total Dilewati : "+totalSkeep);
intent.putExtra("totalWrrong", "Total Salah : "+totalWrrong);
startActivity(intent);
finish();
}
});
}
private void set_Ques_One() {
map=MyArrList.get(index);
setque.setText(map.get("Ques").toString().trim());
rb1.setText(map.get("A1").toString().trim());
rb2.setText(map.get("A2").toString().trim());
rb3.setText(map.get("A3").toString().trim());
rb4.setText(map.get("A4").toString().trim());
MyCAns=map.get("CA1").toString().trim();
//Toast.makeText(getApplicationContext(),"1"+index,2000).show();
}
public void next() {
if(index==9){
// kembali.setVisibility(View.GONE);
// selanjutnya.setVisibility(View.GONE);
kembali.setVisibility(View.VISIBLE);
selanjutnya.setVisibility(View.GONE);
selesai.setVisibility(View.VISIBLE);
}else{
index++;
//Toast.makeText(getApplicationContext(),""+index,2000).show();
map=MyArrList.get(index);
setque.setText(map.get("Ques").toString().trim());
rb1.setText(map.get("A1").toString().trim());
rb2.setText(map.get("A2").toString().trim());
rb3.setText(map.get("A3").toString().trim());
rb4.setText(map.get("A4").toString().trim());
MyCAns=map.get("CA1").toString().trim();
}
}
public void back() {
if(index==0){
kembali.setVisibility(View.GONE);
selanjutnya.setVisibility(View.VISIBLE);
selesai.setVisibility(View.GONE);
}else{
index--;
map=MyArrList.get(index);
setque.setText(map.get("Ques").toString().trim());
rb1.setText(map.get("A1").toString().trim());
rb2.setText(map.get("A2").toString().trim());
rb3.setText(map.get("A3").toString().trim());
rb4.setText(map.get("A4").toString().trim());
MyCAns=map.get("CA1").toString().trim();
}
}
public void set_Your_Ques() {
//Q 1
map=new HashMap<String, String>();
map.put("Ques", "MP1. Method yang digunakan untuk mengkonversi nilai string ke integer dalam Java adalah ?");
map.put("A1", "parseInt()");
map.put("A2", "converseInt()");
map.put("A3", "Cint()");
map.put("A4", "ChangeInt()");
map.put("CA1","parseInt()");
MyArrList.add(map);
//Q 2
map=new HashMap<String, String>();
map.put("Ques", "MP2. Software yang digunakan dalam pengembangan Android adalah ?");
map.put("A1", "Android Studio");
map.put("A2", "Androi Virtual Device Manager");
map.put("A3", "Standart Development Kit Manager");
map.put("A4", "Semua jawaban benar");
map.put("CA1","Semua jawaban benar");
MyArrList.add(map);
//Q 3
map=new HashMap<String, String>();
map.put("Ques", "MP3. Bahasa pemrograman android berbasis ?");
map.put("A1", "Java");
map.put("A2", "PHP");
map.put("A3", "C++");
map.put("A4", "Semua jawaban benar");
map.put("CA1","Java");
MyArrList.add(map);
//Q 4
map=new HashMap<String, String>();
map.put("Ques", "MP4. Android tidak bisa dikembangkan pada komputer dengan sistem operasi ?");
map.put("A1", "Windows XP");
map.put("A2", "DOS");
map.put("A3", "Red Hat");
map.put("A4", "Semua jawaban benar");
map.put("CA1","DOS");
MyArrList.add(map);
//Q 5
map=new HashMap<String, String>();
map.put("Ques", "MP5. Contoh brainware adalah ?");
map.put("A1", "Programmer");
map.put("A2", "Laptop");
map.put("A3", "Android Studio");
map.put("A4", "Semua jawaban benar");
map.put("CA1","Programmer");
MyArrList.add(map);
//Q6
map=new HashMap<String, String>();
map.put("Ques", "MP6. Pemilik dari Android saat ini adalah ?");
map.put("A1", "Android inc.");
map.put("A2", "Google inc.");
map.put("A3", "HTC");
map.put("A4", "Semua jawaban benar");
map.put("CA1","Google inc.");
MyArrList.add(map);
//Q7
map=new HashMap<String, String>();
map.put("Ques", "MP7. Berikut ini adalah keyword yang terdapat dalam Java, kecuali ?");
map.put("A1", "Goto");
map.put("A2", "Break");
map.put("A3", "If");
map.put("A4", "String");
map.put("CA1","String");
MyArrList.add(map);
//Q8
map=new HashMap<String, String>();
map.put("Ques", "MP8. Komentar program dalam java dapat menggunakan perintah ?");
map.put("A1", "/*...*/ saja");
map.put("A2", "// saja");
map.put("A3", "// dan /*...*/");
map.put("A4", "#, // dan /*...*/");
map.put("CA1","// dan /*...*/");
MyArrList.add(map);
//Q9
map=new HashMap<String, String>();
map.put("Ques", "MP9. Berikut ini adalah hak akses yang dapat ditambahkan didepan method Java, kecuali ?");
map.put("A1", "Static");
map.put("A2", "Public");
map.put("A3", "Private");
map.put("A4", "Protected");
map.put("CA1","Static");
MyArrList.add(map);
//Q10
map=new HashMap<String, String>();
map.put("Ques", "MP10. Method yang digunakan untuk mengubah panjang data StringBuffer adalah ?");
map.put("A1", "length()");
map.put("A2", "setLength()");
map.put("A3", "Changelength()");
map.put("A4", "reverse()");
map.put("CA1","setLength()");
MyArrList.add(map);
}
}
Berikut ini hasil runing dari MobileProgramming.java
- UjianSelesai.java
package com.uas.rosya_161011400074;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class UjianSelesai extends Activity {
TextView t1,t2,t3,t4;
Button b1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ujian_selesai);
t1=(TextView)findViewById(R.id.textView1);
t2=(TextView)findViewById(R.id.textView2);
t3=(TextView)findViewById(R.id.textView3);
t4=(TextView)findViewById(R.id.textView4);
b1=(Button)findViewById(R.id.button1);
t1.setText(getIntent().getExtras().getString("totalquestion"));
t2.setText(getIntent().getExtras().getString("totalcurrect"));
t3.setText(getIntent().getExtras().getString("totalSkeep"));
t4.setText(getIntent().getExtras().getString("totalWrrong"));
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(UjianSelesai.this,MainActivity.class);
startActivity(intent);
finish();
}
});
}
}
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class UjianSelesai extends Activity {
TextView t1,t2,t3,t4;
Button b1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ujian_selesai);
t1=(TextView)findViewById(R.id.textView1);
t2=(TextView)findViewById(R.id.textView2);
t3=(TextView)findViewById(R.id.textView3);
t4=(TextView)findViewById(R.id.textView4);
b1=(Button)findViewById(R.id.button1);
t1.setText(getIntent().getExtras().getString("totalquestion"));
t2.setText(getIntent().getExtras().getString("totalcurrect"));
t3.setText(getIntent().getExtras().getString("totalSkeep"));
t4.setText(getIntent().getExtras().getString("totalWrrong"));
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(UjianSelesai.this,MainActivity.class);
startActivity(intent);
finish();
}
});
}
}
Berikut ini hasil runing dari UjianSelesai.java
Berikut video hasil full running dari program aplikasi ini.
Demikian tugas Mobile Programming ini saya buat.
Wassalamu'alaikum Warahmatullahi Wabarakatuh
Tidak ada komentar:
Posting Komentar