Membuat Jadwal Sederhana Dengan List View di Android Studio
A. Deskripsi Program
Program kali ini berhubungan dengan jadwal mata kuliah di sebuah universitas. Fungsi dari program ini antara lain untuk memudahkan mahasiswa dalam mengecek mata kuliah dalam satu semester.
Terdiri dari beberapa palet yaitu ada Button, TextView, EditText dan ListView. Pada program ini terdapat 3 Activity, Activity yang pertama activity_main.xml pada activity ini user harus login terlebih dalulu dengan akun yang sudah terdaftar sebelum masuk ke menu utama. Yang ke dua activity_lupapassword.xml jika user ingin mereset password harapkan untuk memilih menu lupa password untuk mendaftarkan akun terlebih dahulu. Yang ketiga activity_listview.xml yaitu menu utama dalam aplikasi, tempat dimana mahasiswa melihat jadwal mata kuliah. Berikut pemaparan materi dari aplikasi tersebut.
B. Source Code
1. main activity
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=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:srcCompat="@tools:sample/avatars[0]"
android:layout_marginBottom="20sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Welcome"
android:layout_marginBottom="30dp"
android:gravity="center"
android:textSize="24dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="NIM"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
android:layout_marginTop="10dp"/>
<Button
android:id="@+id/btnmasuk"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Masuk"
android:layout_marginTop="20dp"/>
<TextView
android:id="@+id/txtlupa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Lupa Password?"
android:gravity="center"
android:layout_marginTop="5dp"/>
</LinearLayout>
</RelativeLayout>
java
package com.example.aseomaulana161021450137;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button masuk = (Button)findViewById(R.id.btnmasuk);
TextView lupa = (TextView)findViewById(R.id.txtlupa);
masuk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View act2) {
Intent imasuk = new Intent(act2.getContext(),listview.class);
startActivityForResult(imasuk,0);
}
});
lupa.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View lupa) {
Intent ilupa = new Intent(lupa.getContext(),Lupapassword.class);
startActivityForResult(ilupa,0);
}
});
}
}
B. Source Code
1. main activity
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=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:srcCompat="@tools:sample/avatars[0]"
android:layout_marginBottom="20sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Welcome"
android:layout_marginBottom="30dp"
android:gravity="center"
android:textSize="24dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="NIM"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
android:layout_marginTop="10dp"/>
<Button
android:id="@+id/btnmasuk"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Masuk"
android:layout_marginTop="20dp"/>
<TextView
android:id="@+id/txtlupa"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Lupa Password?"
android:gravity="center"
android:layout_marginTop="5dp"/>
</LinearLayout>
</RelativeLayout>
java
package com.example.aseomaulana161021450137;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button masuk = (Button)findViewById(R.id.btnmasuk);
TextView lupa = (TextView)findViewById(R.id.txtlupa);
masuk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View act2) {
Intent imasuk = new Intent(act2.getContext(),listview.class);
startActivityForResult(imasuk,0);
}
});
lupa.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View lupa) {
Intent ilupa = new Intent(lupa.getContext(),Lupapassword.class);
startActivityForResult(ilupa,0);
}
});
}
}
2. Reset Password
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=".Lupapassword">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Reset Password"
android:gravity="center"
android:textSize="24dp"
android:layout_marginBottom="30dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Nama"
android:inputType="text"
android:layout_marginBottom="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="NIM"
android:layout_marginBottom="5dp"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:layout_marginBottom="5dp"
android:inputType="textEmailAddress"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Passwoed Baru"
android:layout_marginBottom="5dp"
android:inputType="text"/>
<Button
android:id="@+id/btnsimpan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Simpan"
android:layout_marginTop="10dp"/>
</LinearLayout>
</RelativeLayout>
Java
package com.example.aseomaulana161021450137;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Lupapassword extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lupapassword);
Button simpan = (Button)findViewById(R.id.btnsimpan);
simpan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View simpan) {
Intent isimpan = new Intent(simpan.getContext(),MainActivity.class);
startActivityForResult(isimpan,0);
}
});
}
}
3. List View atau Jadwal Kuliah
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=".listview">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Jadwal Pelajaran || TI"
android:textAlignment="center"
android:layout_marginTop="20sp"
android:textSize="24dp"/>
<ListView
android:id="@+id/lstitem"
android:layout_marginTop="20sp"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</RelativeLayout>
Java
<?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=".listview">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Jadwal Pelajaran || TI"
android:textAlignment="center"
android:layout_marginTop="20sp"
android:textSize="24dp"/>
<ListView
android:id="@+id/lstitem"
android:layout_marginTop="20sp"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</RelativeLayout>
Demikian deskripsi dan penjelasan singkat dari aplikasi jadwal ini. terimakasih
Komentar
Posting Komentar