MEMBUAT APLIKASI CEK STOCK MATERIAL DENGAN LIST VIEW MENGGUNAKAN ANDROID STUDIO

Assalamualaikum..


A. DESKRIPSI PROGRAM


     Pada kesempatan kali ini saya akan coba membuat Aplikasi Sederhana / Program sederhana yang diperuntukkan untuk cek stock material dalam sebuah Logistik di sebuah proyek.

     Terdiri dari beberapa palet yaitu ada TextView, Button, EditText dan ListView. Pada Program kali ini terdapat 3 Activity :

- main.xml ( pada activity ini user harus login dengan akun yang sudah di daftarkan sebelum masuk halaman utama aplikasi )

- daftar.xml ( jika user belum mempunyai akun, maka harus masuk ke bagian daftar terlebih dahulu agar selanjutnya bisa menggunakan aplikasi tersebut )

- listview.xml ( menu ini adalah menu utama dari keseluruhan aplikasi ini, karena di bagian ini kita sudah bisa melihat jumlah stock material )







Dibawah ini adalah penjelasan dan source nya :


B. SOURCE CODE


1.1 ( Halaman Login )

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"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    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"
            android:layout_marginBottom="10dp"/>

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Email"
            android:inputType="textEmailAddress"
            android:layout_marginBottom="10dp"/>

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Password"
            android:inputType="textPassword"/>

        <Button
            android:id="@+id/btnlogin"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Login"
            android:layout_marginTop="10dp"/>

        <Button
            android:id="@+id/btndaftar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Daftar"
            android:layout_marginTop="5dp"/>


    </LinearLayout>

</RelativeLayout>

JAVA : 

package com.example.rizkipradanaputra;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListAdapter;
import android.widget.ListView;

public class MainActivity extends AppCompatActivity {

    Button login, daftar;

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

        Button login = (Button)findViewById(R.id.btnlogin);
        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View login) {
                Intent ilogin = new Intent(login.getContext(), Listview.class);
                startActivityForResult(ilogin,0);

            }
        });


        Button daftar = (Button)findViewById(R.id.btndaftar);
        daftar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View daftar) {
                Intent idaftar = new Intent(daftar.getContext(),Daftar.class);
                startActivityForResult(idaftar,0);
            }
        });


    }
}


1.2 ( Halaman Daftar )

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=".Daftar">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="Daftar Akun"
            android:textColor="@android:color/black"
            android:textSize="24dp" />
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Nama"
            android:layout_marginTop="50dp"/>
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="NIM"
            android:layout_marginTop="5dp"/>
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Email"
            android:inputType="textEmailAddress"
            android:layout_marginTop="5dp"/>
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Password"
            android:layout_marginTop="5dp"/>

        <Button
            android:id="@+id/btnsimpan"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Daftar"
            android:layout_marginTop="10dp"/>

    </LinearLayout>
</RelativeLayout>


JAVA : 

package com.example.rizkipradanaputra;

import androidx.appcompat.app.AppCompatActivity;

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

public class Daftar extends AppCompatActivity {

    Button daftar;

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

        daftar = (Button)findViewById(R.id.btndaftar);
        daftar.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View regis) {
                Intent idaftar = new Intent(regis.getContext(),MainActivity.class);
                startActivityForResult(idaftar,0);

            }
        });
    }
}


1.3 ( Halaman List View )

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">

        <ListView
            android:id="@+id/listitem"
            android:layout_width="match_parent"
            android:layout_height="600dp" />
        <Button
            android:id="@+id/btnkeluar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Exit"
            android:layout_marginTop="20dp"/>
    </LinearLayout>
</RelativeLayout>

JAVA : 

package com.example.rizkipradanaputra;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;

public class Listview extends AppCompatActivity {
    ListView item;
    String bahan []= {"Pasir","Semen","Paku","Besi 12mm","Kawat"};

    Button exit;

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

        item = (ListView) findViewById(R.id.listitem);
        ArrayAdapter i =new ArrayAdapter(this, android.R.layout.simple_list_item_1, bahan);
        item.setAdapter(i);


        exit = (Button) findViewById(R.id.btnkeluar);
        exit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View keluar) {
                Intent iexit = new Intent(keluar.getContext(),MainActivity.class);
                startActivityForResult(iexit,0);

            }
        });


    }
}


Demikian sedikit penjelasan saya mengenai pembuatan aplikasi sederhana menggunakan Android Studio, semoga bermanfaat untuk semua . .


Komentar

Postingan populer dari blog ini

Kegunaan Menu Form, Report dan SwitchBoard pada MS. Access

NORMALISASI TABEL BASIS DATA MENGGUNAKAN MS. ACCESS