Friday, August 25, 2017

Aplikasi Crud Menggunakan Android Kotlin, Retrofit 2 dan API Lumen Framework

Hii Kuy'.
Kesempatan kali ini saya akan berbagi App Android Crud menggunakan kotlin dengan librarynya menggunakan Retrofit 2 dan Api service menggunakan Framework Lumen. contoh aplikasinya yaitu studi kasus input Nis Siswa dan Nama Siswa. Aplikasi dapat menginput data siswa, menampil data siswa, mengedit data siswa dan menghapus data siswa. Aplikasi ini sebagai bahan latihan untuk teman-teman yang belajar kotlin, yang baru belajar maupun udah lama belajar java android, akan jatuh cinta ke bahasa kotlin, karena apa?
iya karena ketika kita di java android mengetik banyak kode, di kotlin kode yang panjang itu akn lebih singkat, seperti apa aplikasi yang akan kita buat, seperti pada gambar dibawah ini :

Activity_main.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:orientation="vertical"
    tools:context="id.co.imastudio.santri.kotlin2retrofit.MainActivity">
   <android.support.v7.widget.RecyclerView
       android:layout_width="match_parent"
       android:id="@+id/recycler"
       android:layout_height="wrap_content">
     </android.support.v7.widget.RecyclerView>

   <ImageView
       android:id="@+id/img"

       android:src="@mipmap/ic_tambah"
       android:layout_width="70dp"
       android:layout_alignParentBottom="true"
       android:layout_alignParentRight="true"
       android:layout_height="70dp" />


</RelativeLayout>


baca dasar kotlin disini

activity_tambah.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:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="8dp"
   >
   <EditText
       android:gravity="center"
       android:id="@+id/nis"
       android:hint="Input Nis"
       android:layout_width="match_parent"
       android:layout_height="wrap_content" />
    <EditText
        android:gravity="center"
        android:id="@+id/nama"
        android:hint="Input Nama"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    <Button
        android:id="@+id/tambahsiswa"
        android:text="Tambah Siswa"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>
Activity_update_delete.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:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="8dp"
    tools:context="id.co.imastudio.santri.kotlin2retrofit.UpdateDelete">
    <EditText
        android:gravity="center"
        android:id="@+id/edtnis"
        android:hint="Input Nis"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    <EditText
        android:gravity="center"
        android:id="@+id/edtnama"
        android:hint="Input Nama"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    <Button
        android:id="@+id/updatesiswa"
        android:text="Update Siswa"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    <Button
        android:id="@+id/deletesiswa"
        android:text="Hapus Siswa"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
</LinearLayout>


Untuk Jalan Aplikasinya seperti divideo dibawah ini:




lebih lengkap download projectnya disini






NEXT ARTICLE Next Post
PREVIOUS ARTICLE Previous Post
NEXT ARTICLE Next Post
PREVIOUS ARTICLE Previous Post

iklan

 

Delivered by FeedBurner