Sabtu, 06 April 2019

ListView daftar Buah-buahan + form Login & Registrasi (Uas)

  Selamat malam sahabat blogger, kali ini saya akan berbagi aplikasi sederhana daftar buah-buahan menggunakan android studio.. Aplikasi ini pun masih banyak kekurangannya, bagi teman-teman yang masih pemula menggunakan android studio mungkin ini bisa menjadi referensi untuk belajar.

aplikasi ini terdiri dari :

form Login
form Registrasi
Listview

EditTake
RadioButton
Button
ListView
dan jangan lupa kita tambah di app implement android.support.design 28.0.0

yuk kita mulaii...

pertama kita Bikin aplikasi ilmanibrahim1610111400105(misal)






untuk pertama saya buat form login terlebih dahulu..
dan jangan lupa bikin background layar form (Biar keceee...)

lihat gambar di bawah ini:



      drawble nya saya bikin xml baru dengan nama layar.xml (Buat Backgroud layar)



dan penambahan warna di Layout colorxml



hasil nya jadi seperti di bawah ini..


sesudah bikin background 
lalu kita mulai bikin tampilan login dan tampilannya sebagai berikut :




untuk icon /image bisa kita buat di drawable dengan cara Klik Drawable dengan cara pilih New Vector Asset lalu bikin dan cari icon yg sesuai , contoh nya seperti ini :



 Berikut code login.Xml/activitymain.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"
    tools:context=".MainActivity"
    android:background="@drawable/layar"
    android:orientation="vertical"
    android:gravity="center">

    <ImageView
        android:layout_width="350dp"
        android:layout_height="320dp"
        android:layout_marginBottom="20dp"
        android:background="@drawable/icon"/>

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="5dp"
        android:textColorHint="@color/tx"
        app:errorEnabled="true">
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:hint="Email"
            android:inputType="textEmailAddress"/>





    </android.support.design.widget.TextInputLayout>
    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="5dp"
        android:textColorHint="@color/tx"
        app:passwordToggleEnabled="true"
        app:errorEnabled="true">
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:hint="Password"
            android:inputType="textPassword"/>


    </android.support.design.widget.TextInputLayout>
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="LogIn"
        android:layout_marginTop="25dp"
        android:layout_margin="5dp"
        android:background="@drawable/button"
        android:textColor="@color/tx"
        android:onClick="confirm"
        />
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Register"
        android:layout_marginTop="25dp"
        android:layout_margin="5dp"
        android:background="@drawable/button"
        android:textColor="@color/tx"
        android:onClick="regis"
        />




</LinearLayout>

lalu kita buat form registrasi dengan cara pilih new Activity dan berikan nama REGISTRASI

Berikut tampilan dan source code xml form registrasi:

<?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:background="@drawable/layar"
    android:orientation="vertical"
    tools:context=".registrasi">

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="15dp"
        android:textColorHint="@color/tx"
        android:focusableInTouchMode="true"
        app:errorEnabled="true">
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Enter Username"
            android:inputType="textEmailAddress"
            android:textSize="20sp"
            android:layout_marginTop="10dp"/>


    </android.support.design.widget.TextInputLayout>
    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="15dp"
        android:textColorHint="@color/tx"
        android:focusableInTouchMode="true"
        app:errorEnabled="true">
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Enter Email"
            android:inputType="textEmailAddress"
            android:textSize="20sp"
            android:layout_marginTop="10dp"/>


    </android.support.design.widget.TextInputLayout>
    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="15dp"
        android:textColorHint="@color/tx"
        app:errorEnabled="true">
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Enter Password"
            android:inputType="textPassword"
            android:textSize="20sp"
            android:layout_marginTop="10dp"/>


    </android.support.design.widget.TextInputLayout>
    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="15dp"
        android:textColorHint="@color/tx"
        app:errorEnabled="true">
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Confirm Password"
            android:inputType="textPassword"
            android:textSize="20sp"
            android:layout_marginTop="10dp"/>


    </android.support.design.widget.TextInputLayout>

    <RadioGroup
        android:id="@+id/rgbtn"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="15dp"
        android:layout_marginLeft="15dp"

        android:padding="10dp"
        android:orientation="horizontal">
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="@color/tx"
    android:textSize="20sp"
    android:text="Gender"/>
        <RadioButton
            android:id="@+id/ml"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@color/tx"
            android:layout_marginLeft="20sp"
            android:textSize="20sp"
            android:text="Male"/>


        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@color/tx"
            android:textSize="20sp"
            android:text="Female"
            android:layout_marginLeft="20sp"
            />


    </RadioGroup>

    <Button
        android:layout_width="150dp"
        android:layout_height="70dp"
        android:padding="20dp"
        android:layout_gravity="center"
        android:layout_marginTop="20sp"
        android:text="REGISTRASI"
        android:textColor="@color/tx"
        android:background="@drawable/button"
        android:onClick="reg"
        />


</LinearLayout>

Dan tampilan form nya seperti ini :




Lalu kita Buat kode di Mainactivity.Java supaya ketika klik Button bisa tampil acyivity lain:

seperti di bawah ini sourceCode mainactivity:
package com.unpam.ilmanibrahim161011400105;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
    public void confirm( View view){
        Intent intent=new Intent(MainActivity.this,listview.class);
      startActivity(intent);


    } public void regis( View view){
        Intent intent=new Intent(MainActivity.this,registrasi.class);
        startActivity(intent);


    }
}

kita buat activity baru dan di beri nama  listview
 kita buat design dan tambahin listview 
untuk source codenya  bisa di liat di bawah ini


 sourcecode di listview.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:background="@drawable/layar"
    tools:context=".listview">

    <ListView
        android:id="@+id/listvw"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>


baru kita bikin sourcecode di listview.java 
jangan lupa kita pake array :




package com.unpam.ilmanibrahim161011400105;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class listview extends AppCompatActivity {
    ListView lv;
    String [] Menu={"Daftar Buah","Harga Buah","Manfaat Makan Buah","Cara MenanamBuah"};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_listview);

        lv=(ListView)findViewById(R.id.listvw);
        ArrayAdapter adapter= new ArrayAdapter(this,android.R.layout.simple_list_item_single_choice, Menu);
        lv.setAdapter(adapter);

        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int  itemke, long arg3) {
                String itemText=(String)lv.getItemAtPosition(itemke);
                Toast.makeText(getBaseContext(),"Anda Memilih "+ itemText, Toast.LENGTH_LONG).show();
                if(itemText.equals("Daftar Buah")){

              Intent inten=new Intent(arg0.getContext(),daftarbuah.class);
              startActivityForResult(inten,0);




                }
            }
        });

    }
}


lalu kita bikin activity lagi dan beri nama daftar buah:
kali ini saya bikin sesederhana mungkin ,sekedar contoh

berikut source code daftarbuah.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=".daftarbuah">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">


        <ImageView
            android:id="@+id/imgbuah"
            android:layout_width="250dp"
            android:layout_height="200dp"
            android:layout_marginRight="@+id/pisangg"
            android:layout_gravity="center"
            android:padding="50dp"
            android:src="@drawable/pisang" />

        <TextView
            android:id="@+id/pisangg"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:text="Pisang"
            android:textSize="25dp"
            android:textStyle="bold"
            android:layout_marginTop="30dp"
            android:layout_marginLeft="@+id/imgbuah"/>
        <ImageView
            android:id="@+id/apelll"
            android:layout_width="250dp"
            android:layout_height="200dp"
            android:layout_gravity="center"
            android:layout_marginRight="@+id/pisangg"
            android:padding="50dp"
            android:src="@drawable/apel" />

        <TextView
            android:id="@+id/ape"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="APEL"
            android:textSize="25dp"
            android:gravity="center"
            android:textStyle="bold"
            android:layout_marginTop="30dp"
            android:layout_marginLeft="@+id/apelll"/>
    </LinearLayout>

</RelativeLayout>


setelah sudah beres codingannya.kita coba jalan kan ,dan hasilnya seperti di bawah ini:



gambar di bawah ketika kita klik visibity password:

 Tampilan hasil FORM REGISTRASI


 
Untuk tampilan ListView







sekian belajar tentang bikin listview,form login dan registrasi..saya ucapkan terima kasih.
semoga bermanfaat bagi yang ingin belajar .








Senin, 25 Maret 2019

Aplikasi Penjualan Barang Menggunakan Android Studio

  Selamat malam sahabat blogger, kali ini saya akan berbagi aplikasi sederhana penjualan barang menggunakan android studio. Aplikasi ini sangat penting untik menghitung uang kembalian dan lainnya. Aplikasi ini pun masih banyak kekurangannya, bagi teman-teman yang masih pemula menggunakan android studio mungkin ini bisa menjadi referensi untuk belajar.


 Aplikasi nantinya berupa form isian yang terdiri dari :
  • form login (Sebagai tambahan di aplikasi)
  • Nama pelanggan
  • Nama barang
  • Jumlah beli
  • Harga
  • Uang bayar
  • Total belanja
  • Uang kembali
  • Bonus
  • Keterangan
buat project baru dengan cara klik create new project > beri nama project “lapakbarang” (disesuaikan)  > tentukan target sdk nya> pilih empty activity > lanjutkan sampai dengan finish
untuk pertama sawa buat form login terlebih dahulu untuk sebagai tambahan di aplikasi
biar keren gtu..hehe
seperti di bawah ini 




untuk source code di xml login bisa di liat di bawah ini :

<?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:background="@drawable/screen"
    tools:context=".MainActivity">

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

        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="70dp"
            android:gravity="top"
            android:text="LAPAKBARANG.COM"
            android:textColorHint="@color/colorAccent"
            android:textColorLink="@color/colorAccent"
            android:textSize="30sp"
            android:textStyle="bold" />

        <EditText
            android:id="@+id/etemail"
            android:layout_width="323dp"
            android:layout_height="wrap_content"
            android:hint="Usernama / Email Adress"
            android:inputType="textEmailAddress"
            android:textColorHint="@android:color/background_light" />

        <EditText
            android:id="@+id/etpass"
            android:layout_width="323dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="15dp"
            android:ems="10"
            android:hint="Password"
            android:inputType="textPassword"
            android:textColorHint="@android:color/background_light" />

        <Button
            android:id="@+id/button"
            android:layout_width="143dp"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:background="@color/colorAccent"
            android:hint="Login"
            android:text="Login"
            android:textColor="@android:color/background_light"
            android:textColorHint="@android:color/background_light"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="15dp"
            android:layout_marginBottom="70dp"
            android:gravity="top"
            android:text="Forgot Password ?"
            android:textColor="@android:color/background_light"
            android:textColorHint="@color/colorAccent"
            android:textColorLink="@color/colorAccent"
            android:textStyle="bold" />

    </LinearLayout>
</RelativeLayout>

terus kita buat di MainActivity.java

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.TextView;
import android.content.Intent;

public class MainActivity extends AppCompatActivity {

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

        TextView Menu =(TextView) findViewById(R.id.ButtonSave);
        Menu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent a = new Intent(MainActivity.this, menu.class);
                startActivity(a);
            }
        });
    }
}

dan jangan lupa untuk manggil activity lain:
code di mainactivity
     TextView Menu =(TextView) findViewById(R.id.ButtonSave);
        Menu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent a = new Intent(MainActivity.this, menu.class);
                startActivity(a);
            }
        });
    }
}



lanjut ke aplikasi jual barang..
kita bikin  layout aplikasi dengan menggunakan Linearlayout dan  beberapa widget :


  • ScrollView
  • TextView
  • Button
  • EditText
  • RadioButton
Untuk Source Code sebagai berikut :

<?xml version="1.0" encoding="utf-8"?><ScrollView 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="10dp"    tools:context=".MainActivity">
    <LinearLayout        android:layout_width="fill_parent"        android:layout_height="fill_parent"        android:orientation="vertical">
        <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:orientation="horizontal">
            <TextView                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="Nama Pembeli :"                android:textColor="@color/colorAccent"                android:textStyle="bold" />
            <EditText                android:id="@+id/nama_pelanggan"                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:text="" />
        </LinearLayout>
        <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:orientation="horizontal">
            <TextView                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="Nama Barang :"                android:textColor="@color/colorAccent"                android:textStyle="bold" />
            <EditText                android:id="@+id/nama_barang"                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:text="" />
        </LinearLayout>
        <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:orientation="horizontal">
            <TextView                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="Jumlah Barang :"                android:textColor="@color/colorAccent"                android:textStyle="bold" />
            <EditText                android:id="@+id/jml_barang"                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:inputType="number"                android:text="" />
        </LinearLayout>
        <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:orientation="horizontal">
            <TextView                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="Harga : Rp"                android:textColor="@color/colorAccent"                android:textStyle="bold" />
            <EditText                android:id="@+id/harga_barang"                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:inputType="number"                android:text="" />
        </LinearLayout>
        <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:orientation="horizontal">
            <TextView                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="Uang Bayar : Rp"                android:textColor="@color/colorAccent"                android:textStyle="bold" />
            <EditText                android:id="@+id/jml_uang"                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:inputType="number"                android:text="" />
        </LinearLayout>  <LinearLayout      android:layout_width="match_parent"      android:layout_height="wrap_content"      android:orientation="horizontal">      <RadioGroup          android:layout_width="match_parent"          android:layout_height="wrap_content"          android:id="@+id/radioGroupNb"          android:orientation="horizontal"          android:layout_below="@+id/Pby"          >
          <RadioButton              android:layout_width="92dp"              android:layout_height="wrap_content"              android:text="Cash"              android:id="@+id/cashrd"              />
          <RadioButton              android:layout_width="92dp"              android:layout_height="wrap_content"              android:id="@+id/kreditrd"              android:text="Credit"              />

      </RadioGroup>
  </LinearLayout>        <Button            android:id="@+id/proses"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:layout_marginTop="20dp"            android:layout_marginBottom="8dp"            android:background="@color/colorAccent"            android:text="PROSES"            android:textColor="#ffffffff"            android:textStyle="bold" />
        <TextView            android:id="@+id/Pby"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_marginTop="20dp"            android:layout_marginBottom="8dp"            android:text="Pembayaran:"            android:textColor="@color/colorAccent"            android:textStyle="bold" />        <TextView            android:id="@+id/total"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_marginTop="20dp"            android:layout_marginBottom="8dp"            android:text="Total Semua :"            android:textColor="@color/colorAccent"            android:textStyle="bold" />
        <TextView            android:id="@+id/kembalian"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_marginTop="20dp"            android:layout_marginBottom="8dp"            android:text="Uang Kembali :"            android:textColor="@color/colorAccent"            android:textStyle="bold" />
        <TextView            android:id="@+id/bonus"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_marginTop="20dp"            android:layout_marginBottom="8dp"            android:text="Bonus Belanja :"            android:textColor="@color/colorAccent"            android:textStyle="bold" />
        <TextView            android:id="@+id/keterangan"            android:layout_width="wrap_content"            android:layout_height="wrap_content"            android:layout_marginTop="20dp"            android:layout_marginBottom="8dp"            android:text="Keterangan :"            android:textColor="@color/colorAccent"            android:textStyle="bold" />
        <LinearLayout            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:orientation="horizontal">
            <Button                android:id="@+id/reset"                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:layout_margin="5dp"                android:layout_weight="1"                android:background="@color/colorAccent"                android:text="Hapus"                android:textColor="#ffffffff"                android:textStyle="bold" />
            <Button                android:id="@+id/exit"                android:layout_width="match_parent"                android:layout_height="wrap_content"                android:layout_margin="5dp"                android:layout_weight="1"                android:background="@color/colorAccent"                android:text="Keluar"                android:textColor="#ffffffff"                android:textStyle="bold" />
        </LinearLayout>
    </LinearLayout>
</ScrollView>

maka akan tampil seperti ini



Selanjutnya berikan perintah pada textview, button, RradioButton dan komponen lainnya menggunakan bahasa pemrograman java pada MainActivity.java. Untuk kode-kode lengkapnya seperti dibawah ini,

package com.example.jualbarang;

import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;import android.widget.Button;import android.widget.EditText;import android.widget.RadioButton;import android.widget.RadioGroup;import android.widget.TextView;import android.widget.Toast;
public class menu extends AppCompatActivity {

    private EditText editnamapel, editnamabar,            editjumlahbar, editharga, edituangbay;    private Button btnproses;    private Button btnhapus;    private Button btnexit;    private TextView txtnamapel;    private TextView txtnamabar;    private TextView txtjumlahbar;    private TextView txtharga;    private TextView txtuangbay;    private TextView txtbonus;    private TextView txttotalbelanja;    private TextView txtkembali;    private TextView txtketerangan;
   RadioGroup radiogroup;  RadioButton cash,kreditrd;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);
        radiogroup = (RadioGroup) findViewById(R.id.radioGroupNb);        radiogroup.setOnCheckedChangeListener((RadioGroup.OnCheckedChangeListener) this);         cash=(RadioButton)findViewById(R.id.cashrd);         kreditrd=(RadioButton)findViewById(R.id.kreditrd) ;         btnproses=(Button) findViewById(R.id.proses);

        getSupportActionBar().setTitle("Lapak Barang");        editnamapel = (EditText) findViewById(R.id.nama_pelanggan);        editnamabar = (EditText) findViewById(R.id.nama_barang);        editjumlahbar = (EditText) findViewById(R.id.jml_barang);        editharga = (EditText) findViewById(R.id.harga_barang);        edituangbay = (EditText) findViewById(R.id.jml_uang);
        btnproses = (Button) findViewById(R.id.proses);        btnhapus = (Button) findViewById(R.id.reset);        btnexit = (Button) findViewById(R.id.exit);
        txtnamapel = (TextView) findViewById(R.id.nama_pelanggan);        txtnamabar = (TextView) findViewById(R.id.nama_barang);        txtjumlahbar = (TextView) findViewById(R.id.jml_barang);        txtharga = (TextView) findViewById(R.id.harga_barang);        txtuangbay = (TextView) findViewById(R.id.jml_uang);

        txttotalbelanja = (TextView) findViewById(R.id.total);        txtkembali = (TextView) findViewById(R.id.kembalian);        txtketerangan = (TextView) findViewById(R.id.keterangan);        txtbonus = (TextView) findViewById(R.id.bonus);
        btnproses.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String namapelanggan = editnamapel.getText().toString().trim();                String namabarang = editnamabar.getText().toString().trim();                String jumlahbarang = editjumlahbar.getText().toString().trim();                String hargabarang = editharga.getText().toString().trim();                String uangbayar = edituangbay.getText().toString().trim();
                double jb = Double.parseDouble(jumlahbarang);                double h = Double.parseDouble(hargabarang);                double ub = Double.parseDouble(uangbayar);                double total = (jb * h);
                txttotalbelanja.setText("Total Belanja : " + total);
                if (total >= 200000) {
                    txtbonus.setText("Bonus : Harddisk");                } else if (total >= 50000) {
                    txtbonus.setText("Bonus : Keyboard");                } else if (total >= 40000) {
                    txtbonus.setText("Bonus : Mouse");                } else {
                    txtbonus.setText("Bonus : Tidak Ada Bonus");                }

                double uangkembalian = (ub - total);                if (ub < total) {
                    txtketerangan.setText("Keterangan : uang bayar kurang Rp." + (-uangkembalian));                    txtkembali.setText("Uang Kembalian : Rp. 0");                } else {
                    txtketerangan.setText("Keterangan : Tunggu Kembalian");                    txtkembali.setText("Uang Kembalian : " + uangkembalian);                }
            }
        });        btnhapus.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                txtnamapel.setText(" ");                txtnamabar.setText(" ");                txtjumlahbar.setText(" ");                txtharga.setText(" ");                txtuangbay.setText(" ");                txtkembali.setText("Uang Kembali : Rp. 0");                txtketerangan.setText("-");                txtbonus.setText("-");                txttotalbelanja.setText("Total Belanja : Rp 0");
                Toast.makeText(getApplicationContext(), "Data sudah dihapus", Toast.LENGTH_LONG).show();            }
        });        btnexit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                moveTaskToBack(true);            }
        });    }

      }


Jika sudah tidak ada error pada kodingan java di MainAcivity.java. Terakhir adalah running project menggunakan emulator atau langsung ke ponsel android yang kamu miliki.


Maka hasilnya jika kita isi formnya akan seperti gambar dibawah ini.






Sampai disini tutorialnya.semoga aplikasi penjualan tersebut, ini hanya pembelajaran buat saya pribadi dan semoga bermnfaat buat kalian  , Saya ucapkan Terima Kasih