Aplikasi Edukasi Sederhana - Mengenal Buah

Deskripsi

Aplikasi ini merupakan aplikasi edukasi sederhana yang mana dituju untuk anak-anak seusia TK. Analoginya pada gambar buah di dalam aplikasi kita memilih dari beberapa daftar atau list buahnya. Jika jawaban benar maka akan muncul textview berupa "Jawaban Benar", namun jika salah maka akan memunculkan "Jawaban Salah".




Design Activity


XML - Text

Ini merupakan source code daripada XML di dalam aplikasinya.

1.1  activity_main.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="1"
    android:orientation="vertical"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="app.com.example.android.aplikasimengenalbuah.MainActivity">

    <ImageView
        android:id="@+id/tebak_buah"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:layout_gravity="center"
        android:onClick="bt_tebak_buah"
        android:src="@drawable/bgdepan" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/alpukat"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:onClick="bt_alpukat"
            android:src="@drawable/alpukat" />

        <ImageView
            android:id="@+id/apel"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:onClick="bt_apel"
            android:src="@drawable/apel" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/ceri"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:onClick="bt_ceri"
            android:src="@drawable/ceri" />

        <ImageView
            android:id="@+id/durian"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:onClick="bt_durian"
            android:src="@drawable/durian" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/manggis"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:onClick="bt_manggis"
            android:src="@drawable/manggis" />

        <ImageView
            android:id="@+id/strawberry"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:onClick="bt_strawberry"
            android:src="@drawable/strawberry" />
    </LinearLayout>
</LinearLayout>


1.2  activity_splash_screen.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:id="@+id/activity_splash_screen"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="app.com.example.android.aplikasimengenalbuah.SplashScreen">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/bgdepan"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"/>
</RelativeLayout>


1.3  activity_alpukat.xml 


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_alpukat"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:background="#7658ffff"
    android:orientation="vertical"
    tools:context="app.com.example.android.aplikasimengenalbuah.Alpukat">

    <ImageView
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="20dp"
        android:background="#ffff"
        android:src="@drawable/alpukat" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Buah Apakah ini"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="20dp"
        android:textSize="30dp"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/edt_buah_alpukat"
            android:layout_width="match_parent"
            android:layout_height="35dp"
            android:background="#ffff"
            android:hint="Masukkan nama buah"
            android:layout_weight="1"
            android:layout_gravity="bottom"/>
        <Button
            android:id="@+id/bt_proses_alpukat"
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Proses"/>
    </LinearLayout>

    <TextView
        android:id="@+id/hasil_alpukat"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:background="#ffff" />

</LinearLayout>


1.4  activity_apel.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_alpukat"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:background="#7658ffff"
    android:orientation="vertical"
    tools:context="app.com.example.android.aplikasimengenalbuah.Apel">

    <ImageView
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:background="#ffff"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="20dp"
        android:src="@drawable/apel"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Buah Apakah ini"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="20dp"
        android:textSize="30dp"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/edt_buah_apel"
            android:layout_width="match_parent"
            android:layout_height="35dp"
            android:background="#ffff"
            android:hint="Masukkan nama buah"
            android:layout_weight="1"
            android:layout_gravity="bottom"/>
        <Button
            android:id="@+id/bt_proses_apel"
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Proses"/>
    </LinearLayout>
    <TextView
        android:id="@+id/hasil_apel"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:background="#ffff"/>

</LinearLayout>


1.5  activity_ceri.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_alpukat"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:background="#7658ffff"
    android:orientation="vertical"
    tools:context="app.com.example.android.aplikasimengenalbuah.Ceri">

    <ImageView
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:background="#ffff"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="20dp"
        android:src="@drawable/ceri"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Buah Apakah ini"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="20dp"
        android:textSize="30dp"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/edt_buah_ceri"
            android:layout_width="match_parent"
            android:layout_height="35dp"
            android:background="#ffff"
            android:hint="Masukkan nama buah"
            android:layout_weight="1"
            android:layout_gravity="bottom"/>
        <Button
            android:id="@+id/bt_proses_ceri"
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Proses"/>
    </LinearLayout>
    <TextView
        android:id="@+id/hasil_ceri"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:background="#ffff"/>

</LinearLayout>


1.6  activity_durian.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_alpukat"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:background="#7658ffff"
    android:orientation="vertical"
    tools:context="app.com.example.android.aplikasimengenalbuah.Durian">

    <ImageView
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:background="#ffff"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="20dp"
        android:src="@drawable/durian"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Buah Apakah ini"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="20dp"
        android:textSize="30dp"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/edt_buah_durian"
            android:layout_width="match_parent"
            android:layout_height="35dp"
            android:background="#ffff"
            android:hint="Masukkan nama buah"
            android:layout_weight="1"
            android:layout_gravity="bottom"/>
        <Button
            android:id="@+id/bt_proses_durian"
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Proses"/>
    </LinearLayout>
    <TextView
        android:id="@+id/hasil_durian"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:background="#ffff"/>

</LinearLayout>


1.7  activity_manggis.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_alpukat"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:background="#7658ffff"
    android:orientation="vertical"
    tools:context="app.com.example.android.aplikasimengenalbuah.Manggis">

    <ImageView
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:background="#ffff"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="20dp"
        android:src="@drawable/manggis"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Buah Apakah ini"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="20dp"
        android:textSize="30dp"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/edt_buah_manggis"
            android:layout_width="match_parent"
            android:layout_height="35dp"
            android:background="#ffff"
            android:hint="Masukkan nama buah"
            android:layout_weight="1"
            android:layout_gravity="bottom"/>
        <Button
            android:id="@+id/bt_proses_manggis"
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Proses"/>
    </LinearLayout>
    <TextView
        android:id="@+id/hasil_manggis"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:background="#ffff"/>

</LinearLayout>


1.8  activity_strawberry.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_alpukat"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:background="#7658ffff"
    android:orientation="vertical"
    tools:context="app.com.example.android.aplikasimengenalbuah.Strawberry">

    <ImageView
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:background="#ffff"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="20dp"
        android:src="@drawable/strawberry"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Buah Apakah ini"
        android:layout_gravity="center_horizontal"
        android:layout_marginBottom="20dp"
        android:textSize="30dp"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <EditText
            android:id="@+id/edt_buah_strawberry"
            android:layout_width="match_parent"
            android:layout_height="35dp"
            android:background="#ffff"
            android:hint="Masukkan nama buah"
            android:layout_weight="1"
            android:layout_gravity="bottom"/>
        <Button
            android:id="@+id/bt_proses_strawberry"
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Proses"/>
    </LinearLayout>
    <TextView
        android:id="@+id/hasil_strawberry"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="30dp"
        android:background="#ffff"/>

</LinearLayout>



XML - Graphic

Ini merupakan tampilan dari hasil source code XML diatas.

activity_main.xml

activity_splash_screen.xml

activity_alpukat.xml

activity_apel.xml

activity_ceri.xml

activity_durian.xml

activity_manggis.xml

activity_strawberry.xml




Source Code (Java)

Beberapa source code Java di dalam aplikasi.

1.1  MainActivity.java


package app.com.example.android.aplikasimengenalbuah;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void bt_tebak_buah(View view) {
        Toast.makeText(MainActivity.this,"Aplikasi Mengenal Buah",Toast.LENGTH_SHORT).show();
    }

    public void bt_alpukat(View view) {
        Intent i = new Intent(MainActivity.this,Alpukat.class);
        startActivity(i);
    }

    public void bt_apel(View view) {
        Intent i = new Intent(MainActivity.this,Apel.class);
        startActivity(i);
    }

    public void bt_ceri(View view) {
        Intent i = new Intent(MainActivity.this,Ceri.class);
        startActivity(i);
    }

    public void bt_durian(View view) {
        Intent i = new Intent(MainActivity.this,Durian.class);
        startActivity(i);
    }

    public void bt_manggis(View view) {
        Intent i = new Intent(MainActivity.this,Manggis.class);
        startActivity(i);
    }

    public void bt_strawberry(View view) {
        Intent i = new Intent(MainActivity.this,Strawberry.class);
        startActivity(i);
    }
}


1.2  SplashScreen.java


package app.com.example.android.aplikasimengenalbuah;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import androidx.appcompat.app.AppCompatActivity;

public class SplashScreen extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash_screen);
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                Intent i = new Intent(SplashScreen.this, app.com.example.android.aplikasimengenalbuah.MainActivity.class);
                startActivity(i);
                finish();
            }
        },3000L);
    }
    // Handler adalah perintah untuk mulai beberapa waktu lalu pindah activity
    // Intent adalah perintah yang ditujukan untuk pindah dari activity satu ke activity lain
    // startactivity untuk memulai proses Intent finish untuk mengakhiri perintah Intent
    // 3000L adalah durasi perbindahan dari activity satu ke activity lain
}


1.3  Alpukat.java


package app.com.example.android.aplikasimengenalbuah;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Alpukat extends AppCompatActivity {

    EditText editTextAlpukat;
    Button bt_proses;
    TextView hasil;
    String benar = "alpukat";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_alpukat);

        editTextAlpukat = (EditText)findViewById(R.id.edt_buah_alpukat);
        bt_proses = (Button)findViewById(R.id.bt_proses_alpukat);
        hasil = (TextView)findViewById(R.id.hasil_alpukat);

        bt_proses.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (editTextAlpukat.length()==0){
                    Toast.makeText(getApplicationContext(),"Masukkan pilihan terlebih dahulu",Toast.LENGTH_SHORT).show(); //jika masukan kosong
                }
                else {
                    String jawaban = editTextAlpukat.getText().toString(); //mengambil nilai dari editTextAlpukat
                    if (jawaban.equals(benar)){ // membandingkat masukan dengan ketentuan benar  ".equals()" membandingkan nilai String yang tersimpan.
                        String keterangan = "Jawaban Benar";
                        hasil.setText(keterangan);
                    }
                    else{
                        String keterangan = "Jawaban Salah";
                        hasil.setText(keterangan);
                    }
                }

            }
        });
    }
}


1.4  Apel.java


package app.com.example.android.aplikasimengenalbuah;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Apel extends AppCompatActivity {

    EditText editTextApel;
    Button bt_proses;
    TextView hasil;
    String benar = "apel";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_apel);

        editTextApel = (EditText)findViewById(R.id.edt_buah_apel);
        bt_proses = (Button)findViewById(R.id.bt_proses_apel);
        hasil = (TextView)findViewById(R.id.hasil_apel);

        bt_proses.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (editTextApel.length()==0){
                    Toast.makeText(getApplicationContext(),"Masukkan pilihan terlebih dahulu",Toast.LENGTH_SHORT).show(); //jika masukan kosong
                }
                else {
                    String jawaban = editTextApel.getText().toString(); //mengambil nilai dari editTextAlpukat
                    if (jawaban.equals(benar)){ // membandingkat masukan dengan ketentuan benar  ".equals()" membandingkan nilai String yang tersimpan.
                        String keterangan = "Jawaban Benar";
                        hasil.setText(keterangan);
                    }
                    else{
                        String keterangan = "Jawaban Salah";
                        hasil.setText(keterangan);
                    }
                }

            }
        });
    }
}


1.5  Ceri.java


package app.com.example.android.aplikasimengenalbuah;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Ceri extends AppCompatActivity {

    EditText editTextCeri;
    Button bt_proses;
    TextView hasil;
    String benar = "ceri";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ceri);

        editTextCeri = (EditText)findViewById(R.id.edt_buah_ceri);
        bt_proses = (Button)findViewById(R.id.bt_proses_ceri);
        hasil = (TextView)findViewById(R.id.hasil_ceri);

        bt_proses.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (editTextCeri.length()==0){
                    Toast.makeText(getApplicationContext(),"Masukkan pilihan terlebih dahulu",Toast.LENGTH_SHORT).show(); //jika masukan kosong
                }
                else {
                    String jawaban = editTextCeri.getText().toString(); //mengambil nilai dari editTextAlpukat
                    if (jawaban.equals(benar)){ // membandingkat masukan dengan ketentuan benar  ".equals()" membandingkan nilai String yang tersimpan.
                        String keterangan = "Jawaban Benar";
                        hasil.setText(keterangan);
                    }
                    else{
                        String keterangan = "Jawaban Salah";
                        hasil.setText(keterangan);
                    }
                }

            }
        });
    }
}


1.6  Durian.java


package app.com.example.android.aplikasimengenalbuah;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Durian extends AppCompatActivity {

    EditText editTextDurian;
    Button bt_proses;
    TextView hasil;
    String benar = "durian";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_durian);

        editTextDurian = (EditText)findViewById(R.id.edt_buah_durian);
        bt_proses = (Button)findViewById(R.id.bt_proses_durian);
        hasil = (TextView)findViewById(R.id.hasil_durian);

        bt_proses.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (editTextDurian.length()==0){
                    Toast.makeText(getApplicationContext(),"Masukkan pilihan terlebih dahulu",Toast.LENGTH_SHORT).show(); //jika masukan kosong
                }
                else {
                    String jawaban = editTextDurian.getText().toString(); //mengambil nilai dari editTextAlpukat
                    if (jawaban.equals(benar)){ // membandingkat masukan dengan ketentuan benar  ".equals()" membandingkan nilai String yang tersimpan.
                        String keterangan = "Anda benar";
                        hasil.setText(keterangan);
                    }
                    else{
                        String keterangan = "Anda salah";
                        hasil.setText(keterangan);
                    }
                }

            }
        });
    }
}


1.7  Manggis.java


package app.com.example.android.aplikasimengenalbuah;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Manggis extends AppCompatActivity {

    EditText editTextManggis;
    Button bt_proses;
    TextView hasil;
    String benar = "manggis";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_manggis);

        editTextManggis = (EditText)findViewById(R.id.edt_buah_manggis);
        bt_proses = (Button)findViewById(R.id.bt_proses_manggis);
        hasil = (TextView)findViewById(R.id.hasil_manggis);

        bt_proses.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (editTextManggis.length()==0){
                    Toast.makeText(getApplicationContext(),"Masukkan pilihan terlebih dahulu",Toast.LENGTH_SHORT).show(); //jika masukan kosong
                }
                else {
                    String jawaban = editTextManggis.getText().toString(); //mengambil nilai dari editTextAlpukat
                    if (jawaban.equals(benar)){ // membandingkat masukan dengan ketentuan benar  ".equals()" membandingkan nilai String yang tersimpan.
                        String keterangan = "Anda benar";
                        hasil.setText(keterangan);
                    }
                    else{
                        String keterangan = "Anda salah";
                        hasil.setText(keterangan);
                    }
                }

            }
        });
    }
}


1.8  Strawberry.java


package app.com.example.android.aplikasimengenalbuah;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Strawberry extends AppCompatActivity {

    EditText editTextStrawberry;
    Button bt_proses;
    TextView hasil;
    String benar = "strawberry";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_strawberry);

        editTextStrawberry = (EditText)findViewById(R.id.edt_buah_strawberry);
        bt_proses = (Button)findViewById(R.id.bt_proses_strawberry);
        hasil = (TextView)findViewById(R.id.hasil_strawberry);

        bt_proses.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (editTextStrawberry.length()==0){
                    Toast.makeText(getApplicationContext(),"Masukkan pilihan terlebih dahulu",Toast.LENGTH_SHORT).show(); //jika masukan kosong
                }
                else {
                    String jawaban = editTextStrawberry.getText().toString(); //mengambil nilai dari editTextAlpukat
                    if (jawaban.equals(benar)){ // membandingkat masukan dengan ketentuan benar  ".equals()" membandingkan nilai String yang tersimpan.
                        String keterangan = "Anda benar";
                        hasil.setText(keterangan);
                    }
                    else{
                        String keterangan = "Anda salah";
                        hasil.setText(keterangan);
                    }
                }

            }
        });
    }
}


ScreenShoot (Run)

Aplikasi Edukasi Sederhana - Mengenal Buah!


1. Membuka Aplikasi
2. Memulai aplikasi

3. List buah

4. Menebak salah satu buah

Komentar

Postingan populer dari blog ini

Aplikasi Doa Harian (Login, Register, WebView) Sqlite

Kumpulan Doa Sehari-hari