Laporan Aplikasi Kalkulator & Intent PDF
Laporan Aplikasi Kalkulator & Intent PDF
Laporan Aplikasi Kalkulator & Intent PDF
PEMROGRAMAN LANJUT
“MEMBUAT APLIKASI KALKUATOR & INTENT”
Chusnun Nidhom
D3 PJJ Teknik Informatika 2018
2103187019
Activity_Splash_Screen.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SplashScreen">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:padding="20dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Aplikasi Kalkulator"
android:textSize="30dp"
android:textStyle="bold"
android:textAlignment="center"/>
<ImageView
android:paddingTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo_pens"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Chusnun Nidhom"
android:textStyle="bold"
android:padding="10dp"
android:textAlignment="center"
android:textSize="20dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20dp"
android:text="D3 PJJ Teknik Informatika 2018"
android:textAlignment="center"/>
<TextView
android:paddingTop="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="2103187019"
android:textStyle="bold"
android:textSize="20dp"
android:textAlignment="center"/>
</LinearLayout>
Activity_Kalkulator.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="20dp"
tools:context=".Kalkulator">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="MASUKKAN DUA ANGKA"
android:id="@+id/textJudul"
android:textAlignment="center"
android:textSize="26dp"
android:textStyle="bold"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="20"
android:id="@+id/angka_pertama"
android:hint="Masukkan angka pertama"
android:textSize="14dp"
android:layout_below="@+id/textJudul"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="22dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="99"
android:layout_below="@+id/angka_pertama"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="@+id/angka_kedua"
android:hint="Masukkan angka kedua"
android:textSize="14dp" />
<Button
android:layout_width="80dp"
android:layout_height="wrap_content"
android:id="@+id/tambah"
android:layout_below="@+id/angka_kedua"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="18dp"
android:text="+"
android:onClick="tambah"/>
<Button
android:layout_width="80dp"
android:layout_height="wrap_content"
android:id="@+id/kurang"
android:layout_alignBaseline="@+id/tambah"
android:layout_alignBottom="@+id/tambah"
android:layout_toRightOf="@+id/tambah"
android:layout_toEndOf="@+id/tambah"
android:text="-"
android:onClick="kurang"/>
<Button
android:layout_width="80dp"
android:layout_height="wrap_content"
android:id="@+id/bagi"
android:text="/"
android:layout_above="@+id/bersihkan"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:onClick="bagi" />
<Button
android:layout_width="80dp"
android:layout_height="wrap_content"
android:id="@+id/kali"
android:layout_alignBaseline="@id/bagi"
android:layout_alignBottom="@id/bagi"
android:layout_toLeftOf="@+id/bagi"
android:layout_toStartOf="@+id/bagi"
android:text="*"
android:onClick="kali"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/bersihkan"
android:layout_below="@+id/tambah"
android:layout_centerHorizontal="true"
android:text="BERSIHKAN"
android:onClick="bersihkan"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/pindahInten"
android:layout_below="@+id/hasil"
android:paddingTop="10dp"
android:text="Pindah Inten"
android:layout_centerInParent="true"
android:onClick="pindah_inten"/>
<TextView
android:text="HASIL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView1"
android:textAlignment="center"
android:textStyle="normal|bold"
android:textSize="24dp"
android:layout_marginTop="35dp"
android:layout_below="@+id/bersihkan"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0"
android:id="@+id/hasil"
android:layout_below="@id/textView1"
android:layout_centerHorizontal="true"
android:textSize="36dp"
android:textAlignment="center"/>
</RelativeLayout>
Activity_Intent.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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp"
tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Activity 1"
android:textSize="30dp"
android:textStyle="bold" />
<EditText
android:id="@+id/ed_nama"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Masukkan Nama"
android:inputType="text"
android:textSize="18dp" />
<EditText
android:id="@+id/ed_institusi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:hint="Masukkan Institusi"
android:inputType="text"
android:textSize="18dp" />
<Button
android:id="@+id/btn_pindah_data"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Tampilkan" />
<Button
android:id="@+id/btn_pindah_kalkulator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Pindah Kalkulator" />
</LinearLayout>
Activity_Submit.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="18dp"
tools:context=".Submit">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Activity 2"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv_nama"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:text="Nama : "
android:textSize="18dp" />
<TextView
android:id="@+id/tv_institusi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:text="Nama Institusi : "
android:textSize="18dp" />
<Button
android:id="@+id/kembali"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="Kembali"
android:onClick="kembali"
android:textSize="18sp" />
</LinearLayout>
SplashScreen.java
package com.example.kalkulator;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
Kalkulator.java
package com.example.kalkulator;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_kalkulator);
angka_pertama=findViewById(R.id.angka_pertama);
angka_kedua=findViewById(R.id.angka_kedua);
tambah=findViewById(R.id.tambah);
kurang=findViewById(R.id.kurang);
bagi=findViewById(R.id.bagi);
kali=findViewById(R.id.kali);
hasil=findViewById(R.id.hasil);
}
Inten.java
package com.example.kalkulator;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_inten);
edNama = findViewById(R.id.ed_nama);
edInstitusi = findViewById(R.id.ed_institusi);
btnPindahData = findViewById(R.id.btn_pindah_data);
btnPindahKalkulator =
findViewById(R.id.btn_pindah_kalkulator);
btnPindahData.setOnClickListener(this);
btnPindahKalkulator.setOnClickListener(this);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.btn_pindah_data:
pindaDenganData();
break;
case R.id.btn_pindah_kalkulator:
pindahKalkulator();
break;
default:
break;
}
}
private void pindahKalkulator() {
Intent inten = new Intent(Inten.this, Kalkulator.class);
startActivity(inten);
}
Submit.java
package com.example.kalkulator;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_submit);
tvNama=findViewById(R.id.tv_nama);
tvInstitusi=findViewById(R.id.tv_institusi);
String nama=getIntent().getStringExtra(this.EXTRA_NAMA);
String
institusi=getIntent().getStringExtra(this.EXTRA_INSTITUSI);
if (TextUtils.isEmpty(nama)){
tvNama.setText("Nama : ");
}else {
tvNama.setText("Nama : " +nama);
}
if (TextUtils.isEmpty(institusi)){
tvInstitusi.setText("Asal Institusi : ");
}else {
tvInstitusi.setText("Asal Institusi : " +institusi);
}
}