Monday, September 23, 2019

APLIKASI PENCATAT KEUANGAN HARIAN


Pada kali ini saya akan membagikan tentang aplikasi pencatat keuangan yang saya buat, yaitu "DOMPETQU" aplikasi ini berbasis di android KITKAT keatas. jika di intsall di bawah minimum spek android tidak akan bisa.
oke langsung saja kita lihat aplikasi nya.



  • SPLASH SCREEN

splash
yang pertama adalah tampilan awal saat kita membuka aplikasi seperti gambar di atas. tampilan akan muncul selama 4 detik. lalu akan pindah otomatis ke halaman utama.


  • HALAMAN UTAMA


tampilan awal

Pada Tampilan awal kita akan menemukan 4 nama dan 4 kolom isi lalu di tambah dengan 4 tombol yang berfungsi SIMPAN,LIHAT,UBAH dan HAPUS.


jika kita mengisi kolom yang tersedia dan menekan tombol SIMPAN makan akan berhasil dan keluar notifokasi "berhasil KAKA"

lalu jika kita ingin melihat hasil, maka akan keluar seperti.
tampil data

namun jika kita ingin merubah data nya. isi kan "ID" yang tertera di hasil lalu pilih yang ingin di ubah dan tekan lagi tombol UBAH. maka akan berubah seperti ini.

ubah data
Ubah data berhasil. lanjut untuk menghapus data. Cara nya sama yaitu dengan mengisi kan "ID" yang ingin di hapus, lalu tekan tombol hapus makan akan jadi seperti ini.
hapus data

Aplikasi yang saya buat ini menggunakan SQLITE android yang dimana memakai CRUD sebagai navigasi nya.



desain mainactivity 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"    android:background="@color/colorPrimary">
    <LinearLayout        android:layout_width="match_parent"        android:layout_height="match_parent"        android:gravity="center"        android:orientation="vertical">
        <TextView            android:id="@+id/textView"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:text="JENIS" />
        <EditText            android:id="@+id/editText"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:ems="10"            android:inputType="textPersonName"            android:text="TAMBAH/KURANG" />
        <TextView            android:id="@+id/textView2"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:text="NOMINAL" />
        <EditText            android:id="@+id/editText2"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:ems="10"            android:inputType="number"            android:text="" />
        <TextView            android:id="@+id/textView3"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:text="DESKRIPSI" />
        <EditText            android:id="@+id/editText3"            android:layout_width="match_parent"            android:layout_height="200dp"            android:ems="10"            android:inputType="textPersonName" />
        <TextView            android:id="@+id/textView4"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:text="ID" />
        <EditText            android:id="@+id/editText4"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:ems="10"            android:inputType="textPersonName" />
        <Button            android:id="@+id/button1"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:text="SIMPAN" />
        <Button            android:id="@+id/button2"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:text="LIHAT HASIL" />
        <Button            android:id="@+id/button3"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:text="UBAH" />
        <Button            android:id="@+id/button4"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:text="HAPUS" />    </LinearLayout>


</RelativeLayout>

  • Source Code untuk mainActivity.java

package com.e.dompetnya;
import androidx.appcompat.app.AlertDialog;import androidx.appcompat.app.AppCompatActivity;
import android.database.Cursor;import android.os.Bundle;import android.view.View;import android.widget.Button;import android.widget.EditText;import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
    DataBaseHelper myDb;    EditText editJenis,editNominal,editDeskripsi,editId;    Button btnSimpan;    Button btnList;    Button btnUbah;    Button btnHapus;
    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        myDb = new DataBaseHelper(this);
        editJenis = (EditText) findViewById(R.id.editText);        editNominal = (EditText) findViewById(R.id.editText2);        editDeskripsi = (EditText) findViewById(R.id.editText3);        editId = (EditText) findViewById(R.id.editText4);        btnSimpan = (Button) findViewById(R.id.button1);        btnList = (Button) findViewById(R.id.button2);        btnUbah = (Button) findViewById(R.id.button3);        btnHapus = (Button) findViewById(R.id.button4);        AddBtnSimpan();        viewBtnList();        UpdateData();        DeleteData();    }
    public void DeleteData() {
        btnHapus.setOnClickListener(
                new View.OnClickListener() {
                    @Override                    public void onClick(View v) {
                        Integer deleteRows = myDb.deleteData(editId.getText() .toString());                        if (deleteRows > 0)
                            Toast.makeText(MainActivity.this,"Data di Hapus",Toast.LENGTH_LONG).show();                        else                            Toast.makeText(MainActivity.this,"Data gagal Hapus",Toast.LENGTH_LONG).show();
                    }
                }
        );    }

    public void AddBtnSimpan() {
        btnSimpan.setOnClickListener(
                new View.OnClickListener() {
                    @Override                    public void onClick(View v) {
                        boolean isInserted= myDb.insertData(editJenis.getText().toString(),                                editNominal.getText().toString(),                                editDeskripsi.getText().toString());                        if (isInserted =true)
                            Toast.makeText(MainActivity.this,"Berhasil KAKA", Toast.LENGTH_LONG).show();                        else                            Toast.makeText(MainActivity.this,"Gagal KAKA", Toast.LENGTH_LONG).show();
                    }
                }
        );    }
    public void UpdateData() {
        btnUbah.setOnClickListener(
                new View.OnClickListener() {
                    @Override                    public void onClick(View v) {
                        boolean isUpdate = myDb.updateData(editId.getText() .toString() ,editJenis.getText() .toString() ,editNominal.getText() .toString() ,editDeskripsi.getText() .toString());                        if (isUpdate == true )
                            Toast.makeText(MainActivity.this,"DIupdate KAKA", Toast.LENGTH_LONG).show();                        else                            Toast.makeText(MainActivity.this,"Gagal KAKA", Toast.LENGTH_LONG).show();                    }
                }
        );    }

    public void viewBtnList() {
        btnList.setOnClickListener(
                new View.OnClickListener() {
                    @Override                    public void onClick(View v) {
                       Cursor res = myDb.getAllData();                       if (res.getCount() == 0) {
                           //show message                           showMessage("eror guys","Nothing found");                           return;                       }

                       StringBuffer buffer = new StringBuffer();                       while (res.moveToNext()) {
                           buffer.append("Id :"+ res.getString(0)+"\n");                           buffer.append("JENIS :"+ res.getString(1)+"\n");                           buffer.append("NOMINAL :"+ res.getString(2)+"\n");                           buffer.append("DESKRIPSI :"+ res.getString(3)+"\n\n");                       }

                       //show all data                        showMessage("Data",buffer.toString());                    }
                }
        );    }

    public void showMessage(String title,String Message) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);        builder.setCancelable(true);        builder.setTitle(title);        builder.setMessage(Message);        builder.show();    }

}

  • Source Code Database nya(SQLite)

package com.e.dompetnya;
import android.content.ContentValues;import android.content.Context;import android.database.Cursor;import android.database.sqlite.SQLiteDatabase;import android.database.sqlite.SQLiteOpenHelper;
import androidx.annotation.Nullable;
public class DataBaseHelper extends SQLiteOpenHelper {
    public static final String DATABASE_NAME = "transaksi.db";    public static final String TABLE_NAME = "transaksi_table";    public static final String BARIS_1 = "Id";    public static final String BARIS_2 = "JENIS";    public static final String BARIS_3 = "NOMINAL";    public static final String BARIS_4 = "DESKRIPSI";
    public DataBaseHelper(Context context) {
        super(context, DATABASE_NAME, null, 1);    }

    @Override    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table " + TABLE_NAME +" (ID INTEGER PRIMARY KEY AUTOINCREMENT,JENIS TEXT,NOMINAL INTEGER,DESKRIPSI TEXT)");    }

    @Override    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
       db.execSQL("DROP TABLE IF EXISTS " +TABLE_NAME);       onCreate(db);    }

    public boolean insertData(String JENIS,String NOMINAL,String DESKRIPSI) {
        SQLiteDatabase db = this.getWritableDatabase();        ContentValues contentValues = new ContentValues();        contentValues.put(BARIS_2 ,JENIS);        contentValues.put(BARIS_3 ,NOMINAL);        contentValues.put(BARIS_4 ,DESKRIPSI);        long result = db.insert(TABLE_NAME,null ,contentValues);        if (result == -1)
            return false;        else            return true;    }

    public Cursor getAllData()  {
        SQLiteDatabase db = this.getWritableDatabase();        Cursor res = db.rawQuery("select * from "+TABLE_NAME,null);        return res;    }

    public boolean updateData(String id,String JENIS,String NOMINAL,String DESKRIPSI) {
        SQLiteDatabase db = this.getWritableDatabase();        ContentValues contentValues = new ContentValues();        contentValues.put(BARIS_1 ,id);        contentValues.put(BARIS_2 ,JENIS);        contentValues.put(BARIS_3 ,NOMINAL);        contentValues.put(BARIS_4 ,DESKRIPSI);        db.update(TABLE_NAME, contentValues, "Id = ?",new String[] { id });        return true;    }

    public Integer deleteData (String id) {
        SQLiteDatabase db = this.getWritableDatabase();        return db.delete(TABLE_NAME, "Id = ?",new String[] {id});    }
}


  • Source Code SplashScreen JAVA

package com.dompet;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;import android.os.Bundle;import android.view.animation.Animation;import android.view.animation.AnimationUtils;import android.widget.ImageView;import android.widget.TextView;
import org.w3c.dom.Text;
public class MainActivity extends AppCompatActivity {
    private TextView tv ;    private ImageView iv ;
    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        tv = (TextView) findViewById(R.id.tv);        iv = (ImageView) findViewById(R.id.iv);        Animation myanim = AnimationUtils.loadAnimation(this,R.anim.mytransisi);        tv.startAnimation(myanim);        iv.startAnimation(myanim);        final Intent i = new Intent(this,HomeActivity.class);        Thread timer =new Thread() {
            public void run() {
                try {
                    sleep(5000);                } catch (InterruptedException e) {
                    e.printStackTrace();                } finally {
                    startActivity(i);
                }
            }
        };        timer.start();    }
}

  • Source Code SplashScreen 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"    android:background="@color/colorPrimary">
    <LinearLayout        android:layout_width="match_parent"        android:layout_height="match_parent"        android:gravity="center"        android:orientation="vertical">
        <ImageView            android:id="@+id/iv"            android:layout_width="200dp"            android:layout_height="200dp"            android:layout_gravity="center"            android:src="@drawable/dompet" />
        <TextView            android:id="@+id/tv"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_gravity="center"            android:layout_marginTop="10dp"            android:text="DOMPETQU"            android:textColor="@color/white"            android:textSize="30sp"            android:textStyle="bold" />
    </LinearLayout>
</RelativeLayout>


CONTOH APLIKASI BERJALAN DI HANPHONE ANDROID

aplikasi berjakan

Sekian dari saya jika ada yang kurang atau salah mohon di maafkan. Wassalam.

Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © Rekkyar - Blogger Templates - Powered by Blogger - Designed by Johanes Djogan -