UAS Mobile Programming
UAS
MOBILE PROGRAMMING
Membuat Aplikasi Input Data Karyawan Sederhana menggunakan SQLite Android Studio
A. Pengertian
SQLite adalah perpustakaan perangkat lunak yang menerapkan engine database SQL secara mandiri, tanpa memerlukan server, tanpa perlu melakukan konfigurasi, dan bersifat transaksional. SQLite adalah engine database SQL yang paling banyak digunakan di dunia. SQLite merupakan proyek yang bersifat public domain yang dikerjakan oleh D. Richard Hipp.
SQLite adalah sebuah engine database SQL yang langsung tertanam atau pada aplikasi. Tidak seperti kebanyakan database SQL lainnya, SQLite tidak memiliki server yang terpisah dari aplikasi. SQLite membaca dan menulis langsung ke file disk biasa. Database SQLite memiliki fitur lengkap dengan banyak tabel, indexs, trigger, dan tampilan, serta tersimpan pada satu file tunggal dalam hard-disk. Format file databasenya bersifat cross-platform. Sehingga Anda dapat dengan bebas menyalin database antara sistem 32-bit dan 64-bit atau antara arsitektur yang berbeda flatform. Fitur-fitur ini membuat SQLite menjadi pilihan populer sebagai Application File Format.
B. Implementasi Code
SQLiteOpenHelper adalah sebuah class yang di gunakan untuk mengatur versi database dan pembuatan database.
dan juga SQLiteOpenHelper juga memiliki beberapa method yaitu:
dan juga SQLiteOpenHelper juga memiliki beberapa method yaitu:
- onOpen(SQLiteDatabase): Method ini berfungsi untuk membuka database yang sudah ada
- onCreate(SQLiteDatabase): Method ini berfungsi untuk membuat database jika sudah ada
- onUpdate(SQLiteDatabase, int, int): Method ini berfungsi untuk mengubah database
DataHelper.Java
package com.androidsmt6.datapekerja;
/**
* Created by Fakhri Alauddin on 07 Januari 2019
*/
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class DataHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "biodatapekerja_db";
private static final int DATABASE_VERSION =1;
public DataHelper (Context context){
super(context,DATABASE_NAME,null,DATABASE_VERSION);
// TODO Auto-generated constructor stub }
@Override
public void onCreate (SQLiteDatabase db){
// TODO Auto-generated method stub
String sql = "create table biodatapekerja(nik integer primary key, nama text null, tgl text null, jk text null, " +
"alamat text null, jabatan text null, golongan text null);";
Log.d("Data", "onCreate:" + sql); db.execSQL(sql);
sql = "INSERT INTO biodatapekerja (nik, nama, tgl, jk, alamat, jabatan, golongan) VALUES ('12345','Fadly','2018-07-05','Laki-laki','Binong Permai','Teknisi','C');";
db.execSQL(sql);
}
@Override public void onUpgrade (SQLiteDatabase arg0, int arg1, int arg2){
// TODO Auto-generated method stub }
}
Setelah itu membuat Class Activity baru, yaitu:
- Buat Biodata
- Lihat Biodata
- Update Biodata
- activity_buat_biodata
- lihat_biodata
- update_biodata
Source Code MainActivity.Java
package com.androidsmt6.datapekerja;
/**
* Created by Fakhri Alauddin on 07 Januari 2019
*/
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
String[] daftar;
ListView Listview01;
Menu menu;
protected Cursor cursor;
DataHelper dbcenter;
public static MainActivity ma;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn=(Button) findViewById(R.id.button2);
btn.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View arg0) {
//Auto-generated method stub
startActivity(new Intent(MainActivity.this, BuatBiodata.class)); }
}); ;
ma = this;
dbcenter = new DataHelper(this);
RefrestList();
}
public void RefrestList(){
SQLiteDatabase db = dbcenter.getReadableDatabase();
cursor = db.rawQuery("SELECT * FROM biodatapekerja", null);
daftar = new String[cursor.getCount()];
cursor.moveToFirst();
for (int cc=0; cc < cursor.getCount(); cc++){
cursor.moveToPosition(cc);
daftar[cc] = cursor.getString(1).toString();
}
Listview01 = (ListView)findViewById(R.id.listView1);
Listview01.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, daftar));
Listview01.setSelected(true);
Listview01.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView arg0, View arg1, int arg2, long arg3) {
final String selection = daftar[arg2]; //.getItemAtPosition(arg2).toString();
final CharSequence[] dialogitem = {"Lihat Biodata", "Update Biodata", "Hapus Biodata"};
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("Pilihan");
builder.setItems(dialogitem, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
switch(item){
case 0 :
Intent i = new Intent(getApplicationContext(), LihatBiodata.class);
i.putExtra("nama", selection);
startActivity(i);
break;
case 1 :
Intent in = new Intent(getApplicationContext(), UpdateBiodata.class);
in.putExtra("nama", selection);
startActivity(in);
break;
case 2 :
SQLiteDatabase db = dbcenter.getWritableDatabase();
db.execSQL("delete from biodata where nama = '"+selection+"'");
RefrestList();
break;
}
}
});
builder.create().show();
}});
((ArrayAdapter)Listview01.getAdapter()).notifyDataSetInvalidated();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Source Code activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:background="#FFCCFFCC"
tools:context=".MainActivity" >
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/button1"
style="?android:attr/borderlessButtonStyle"
android:text="Tambah Data Karyawan" />
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/button2" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
</ListView>
<ImageView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/kantorku"
android:alpha="0.4"
android:layout_centerVertical="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
</RelativeLayout>
SQLiteDatabase adalah sebuah class dasar yang bekerja , untuk database sqlite di perangkat Android. SqLiteDatabase akan menjalankan perintah SQL secara langsung dengan method exceSQL(). Dan juga akan melakukan manajamen database secara umum lainya , method yang digunakan seperti : Insert() ,Update () dan ,Delete ().
Source Code BuatBiodata.Java
package com.androidsmt6.datapekerja;
/**
* Created by Fakhri Alauddin on 07 Januari 2019
*/
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class BuatBiodata extends AppCompatActivity{
protected Cursor cursor;
DataHelper dbHelper;
Button ton1, ton2 ;
EditText text1, text2, text3, text4, text5, text6, text7;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_buat_biodata);
dbHelper = new DataHelper(this);
text1 = (EditText) findViewById(R.id.editText1);
text2 = (EditText) findViewById(R.id.editText2);
text3 = (EditText) findViewById(R.id.editText3);
text4 = (EditText) findViewById(R.id.editText4);
text5 = (EditText) findViewById(R.id.editText5);
text6 = (EditText) findViewById(R.id.editText6);
text7= (EditText) findViewById(R.id.editText7);
ton1 = (Button) findViewById(R.id.button1);
ton2 = (Button) findViewById(R.id.button2);
ton1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
SQLiteDatabase db = dbHelper.getWritableDatabase();
db.execSQL("insert into biodatapekerja(nik, nama, tgl, jk, alamat, jabatan, golongan) values('" +
text1.getText().toString()+"','"+
text2.getText().toString() +"','" +
text3.getText().toString()+"','"+
text4.getText().toString() +"','" +
text5.getText().toString() +"','" +
text6.getText().toString() +"','" +
text7.getText().toString() + "')");
Toast.makeText(getApplicationContext(), "Berhasil", Toast.LENGTH_LONG).show();
MainActivity.ma.RefrestList();
finish();
}
});
ton2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
finish();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
/**
* Created by Fakhri Alauddin on 07 Januari 2019
*/
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class BuatBiodata extends AppCompatActivity{
protected Cursor cursor;
DataHelper dbHelper;
Button ton1, ton2 ;
EditText text1, text2, text3, text4, text5, text6, text7;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_buat_biodata);
dbHelper = new DataHelper(this);
text1 = (EditText) findViewById(R.id.editText1);
text2 = (EditText) findViewById(R.id.editText2);
text3 = (EditText) findViewById(R.id.editText3);
text4 = (EditText) findViewById(R.id.editText4);
text5 = (EditText) findViewById(R.id.editText5);
text6 = (EditText) findViewById(R.id.editText6);
text7= (EditText) findViewById(R.id.editText7);
ton1 = (Button) findViewById(R.id.button1);
ton2 = (Button) findViewById(R.id.button2);
ton1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
SQLiteDatabase db = dbHelper.getWritableDatabase();
db.execSQL("insert into biodatapekerja(nik, nama, tgl, jk, alamat, jabatan, golongan) values('" +
text1.getText().toString()+"','"+
text2.getText().toString() +"','" +
text3.getText().toString()+"','"+
text4.getText().toString() +"','" +
text5.getText().toString() +"','" +
text6.getText().toString() +"','" +
text7.getText().toString() + "')");
Toast.makeText(getApplicationContext(), "Berhasil", Toast.LENGTH_LONG).show();
MainActivity.ma.RefrestList();
finish();
}
});
ton2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
finish();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Source Code activity_buat_biodata.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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".BuatBiodata"
android:background="#FFCCFFCC">
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1" >
<requestFocus />
</EditText>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="NIK"/>
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/textView2"
android:layout_below="@+id/textView2">
</EditText>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView2"
android:layout_alignLeft="@+id/editText1"
android:layout_below="@+id/editText1"
android:layout_marginTop="10dp"
android:text="Nama Karyawan" />
<EditText
android:id="@+id/editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_below="@+id/textView3" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText2"
android:layout_below="@+id/editText2"
android:layout_marginTop="10dp"
android:text="Tanggal Lahir" />
<EditText
android:id="@+id/editText4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView4"
android:layout_below="@+id/textView4" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText3"
android:layout_below="@+id/editText3"
android:layout_marginTop="10dp"
android:text="Jenis Kelamin" />
<EditText
android:id="@+id/editText5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView5"
android:layout_below="@+id/textView5" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText4"
android:layout_below="@+id/editText4"
android:layout_marginTop="10dp"
android:text="Alamat" />
<EditText
android:id="@+id/editText6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView6"
android:layout_below="@+id/textView6" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText5"
android:layout_below="@+id/editText5"
android:layout_marginTop="10dp"
android:text="Jabatan" />
<EditText
android:id="@+id/editText7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView7"
android:layout_below="@+id/textView7" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText6"
android:layout_below="@+id/editText6"
android:layout_marginTop="10dp"
android:text="Golongan" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/editText7"
android:layout_alignParentBottom="true"
android:layout_marginLeft="262dp"
android:layout_marginBottom="8dp"
android:text="Simpan" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="12dp"
android:layout_marginLeft="-77dp"
android:layout_marginBottom="6dp"
android:layout_toRightOf="@+id/textView4"
android:text="Back"
android:layout_alignParentLeft="true" />
</RelativeLayout>
<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".BuatBiodata"
android:background="#FFCCFFCC">
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1" >
<requestFocus />
</EditText>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="NIK"/>
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/textView2"
android:layout_below="@+id/textView2">
</EditText>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView2"
android:layout_alignLeft="@+id/editText1"
android:layout_below="@+id/editText1"
android:layout_marginTop="10dp"
android:text="Nama Karyawan" />
<EditText
android:id="@+id/editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_below="@+id/textView3" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText2"
android:layout_below="@+id/editText2"
android:layout_marginTop="10dp"
android:text="Tanggal Lahir" />
<EditText
android:id="@+id/editText4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView4"
android:layout_below="@+id/textView4" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText3"
android:layout_below="@+id/editText3"
android:layout_marginTop="10dp"
android:text="Jenis Kelamin" />
<EditText
android:id="@+id/editText5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView5"
android:layout_below="@+id/textView5" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText4"
android:layout_below="@+id/editText4"
android:layout_marginTop="10dp"
android:text="Alamat" />
<EditText
android:id="@+id/editText6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView6"
android:layout_below="@+id/textView6" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText5"
android:layout_below="@+id/editText5"
android:layout_marginTop="10dp"
android:text="Jabatan" />
<EditText
android:id="@+id/editText7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView7"
android:layout_below="@+id/textView7" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText6"
android:layout_below="@+id/editText6"
android:layout_marginTop="10dp"
android:text="Golongan" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/editText7"
android:layout_alignParentBottom="true"
android:layout_marginLeft="262dp"
android:layout_marginBottom="8dp"
android:text="Simpan" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="12dp"
android:layout_marginLeft="-77dp"
android:layout_marginBottom="6dp"
android:layout_toRightOf="@+id/textView4"
android:text="Back"
android:layout_alignParentLeft="true" />
</RelativeLayout>
Source Code LihatBiodata.Java
package com.androidsmt6.datapekerja;
/**
* Created by Fakhri Alauddin on 08 Januari 2019
*/
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class LihatBiodata extends AppCompatActivity {
protected Cursor cursor;
DataHelper dbHelper;
Button ton2;
TextView text1, text2, text3, text4, text5, text6, text7;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.lihat_biodata);
dbHelper = new DataHelper(this);
text1 = (TextView) findViewById(R.id.textView1);
text2 = (TextView) findViewById(R.id.textView2);
text3 = (TextView) findViewById(R.id.textView3);
text4 = (TextView) findViewById(R.id.textView4);
text5 = (TextView) findViewById(R.id.textView5);
text6 = (TextView) findViewById(R.id.textView6);
text7 = (TextView) findViewById(R.id.textView7);
SQLiteDatabase db = dbHelper.getReadableDatabase();
cursor = db.rawQuery("SELECT * FROM biodatapekerja WHERE nama = '" +
getIntent().getStringExtra("nama") + "'",null);
cursor.moveToFirst();
if (cursor.getCount()>0)
{
cursor.moveToPosition(0);
text1.setText(cursor.getString(0).toString());
text2.setText(cursor.getString(1).toString());
text3.setText(cursor.getString(2).toString());
text4.setText(cursor.getString(3).toString());
text5.setText(cursor.getString(4).toString());
text6.setText(cursor.getString(5).toString());
text7.setText(cursor.getString(6).toString());
}
ton2 = (Button)findViewById(R.id.button1);
ton2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
//TODO Auto-generated method stub
finish();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
/**
* Created by Fakhri Alauddin on 08 Januari 2019
*/
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class LihatBiodata extends AppCompatActivity {
protected Cursor cursor;
DataHelper dbHelper;
Button ton2;
TextView text1, text2, text3, text4, text5, text6, text7;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.lihat_biodata);
dbHelper = new DataHelper(this);
text1 = (TextView) findViewById(R.id.textView1);
text2 = (TextView) findViewById(R.id.textView2);
text3 = (TextView) findViewById(R.id.textView3);
text4 = (TextView) findViewById(R.id.textView4);
text5 = (TextView) findViewById(R.id.textView5);
text6 = (TextView) findViewById(R.id.textView6);
text7 = (TextView) findViewById(R.id.textView7);
SQLiteDatabase db = dbHelper.getReadableDatabase();
cursor = db.rawQuery("SELECT * FROM biodatapekerja WHERE nama = '" +
getIntent().getStringExtra("nama") + "'",null);
cursor.moveToFirst();
if (cursor.getCount()>0)
{
cursor.moveToPosition(0);
text1.setText(cursor.getString(0).toString());
text2.setText(cursor.getString(1).toString());
text3.setText(cursor.getString(2).toString());
text4.setText(cursor.getString(3).toString());
text5.setText(cursor.getString(4).toString());
text6.setText(cursor.getString(5).toString());
text7.setText(cursor.getString(6).toString());
}
ton2 = (Button)findViewById(R.id.button1);
ton2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
//TODO Auto-generated method stub
finish();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Source Code lihat_biodata.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".LihatBiodata"
android:background="#FFCCFFCC">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="104dp"
android:layout_marginTop="20dp"
android:text="TextView" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginTop="20dp"
android:text="TextView" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView2"
android:layout_below="@+id/textView2"
android:layout_marginTop="20dp"
android:text="TextView" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView3"
android:layout_below="@+id/textView3"
android:layout_marginTop="20dp"
android:text="TextView" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView4"
android:layout_below="@+id/textView4"
android:layout_marginTop="20dp"
android:text="TextView" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView5"
android:layout_below="@+id/textView5"
android:layout_marginTop="20dp"
android:text="TextView" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView6"
android:layout_below="@+id/textView6"
android:layout_marginTop="20dp"
android:text="TextView" />
<TextView
android:id="@+id/TextView05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView5"
android:layout_alignBottom="@+id/textView5"
android:layout_alignLeft="@+id/TextView03"
android:text="Alamat" />
<TextView
android:id="@+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView4"
android:layout_alignBottom="@+id/textView4"
android:layout_alignLeft="@+id/TextView04"
android:text="Jenis Kelamin" />
<TextView
android:id="@+id/TextView04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView3"
android:layout_alignBottom="@+id/textView3"
android:layout_alignLeft="@+id/TextView02"
android:text="Tanggal Lahir" />
<TextView
android:id="@+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView2"
android:layout_alignBottom="@+id/textView2"
android:layout_alignLeft="@+id/TextView01"
android:text="Nama Karyawan" />
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView2"
android:layout_alignParentLeft="true"
android:text="Nik" />
<TextView
android:id="@+id/TextView06"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView6"
android:layout_alignBottom="@+id/textView7"
android:layout_alignLeft="@+id/TextView01"
android:text="Jabatan" />
<TextView
android:id="@+id/TextView07"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView7"
android:layout_alignBottom="@+id/textView5"
android:layout_alignLeft="@+id/TextView01"
android:text="Golongan" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/TextView07"
android:layout_alignLeft="@+id/TextView05"
android:layout_alignParentStart="true"
android:layout_marginStart="15dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="54dp"
android:text="Back"
android:layout_alignParentLeft="true" />
</RelativeLayout>
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".LihatBiodata"
android:background="#FFCCFFCC">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="104dp"
android:layout_marginTop="20dp"
android:text="TextView" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginTop="20dp"
android:text="TextView" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView2"
android:layout_below="@+id/textView2"
android:layout_marginTop="20dp"
android:text="TextView" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView3"
android:layout_below="@+id/textView3"
android:layout_marginTop="20dp"
android:text="TextView" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView4"
android:layout_below="@+id/textView4"
android:layout_marginTop="20dp"
android:text="TextView" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView5"
android:layout_below="@+id/textView5"
android:layout_marginTop="20dp"
android:text="TextView" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/textView6"
android:layout_below="@+id/textView6"
android:layout_marginTop="20dp"
android:text="TextView" />
<TextView
android:id="@+id/TextView05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView5"
android:layout_alignBottom="@+id/textView5"
android:layout_alignLeft="@+id/TextView03"
android:text="Alamat" />
<TextView
android:id="@+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView4"
android:layout_alignBottom="@+id/textView4"
android:layout_alignLeft="@+id/TextView04"
android:text="Jenis Kelamin" />
<TextView
android:id="@+id/TextView04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView3"
android:layout_alignBottom="@+id/textView3"
android:layout_alignLeft="@+id/TextView02"
android:text="Tanggal Lahir" />
<TextView
android:id="@+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView2"
android:layout_alignBottom="@+id/textView2"
android:layout_alignLeft="@+id/TextView01"
android:text="Nama Karyawan" />
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView2"
android:layout_alignParentLeft="true"
android:text="Nik" />
<TextView
android:id="@+id/TextView06"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView6"
android:layout_alignBottom="@+id/textView7"
android:layout_alignLeft="@+id/TextView01"
android:text="Jabatan" />
<TextView
android:id="@+id/TextView07"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView7"
android:layout_alignBottom="@+id/textView5"
android:layout_alignLeft="@+id/TextView01"
android:text="Golongan" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/TextView07"
android:layout_alignLeft="@+id/TextView05"
android:layout_alignParentStart="true"
android:layout_marginStart="15dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="54dp"
android:text="Back"
android:layout_alignParentLeft="true" />
</RelativeLayout>
Source Code UpdateBiodata.Java
package com.androidsmt6.datapekerja;
/**
* Created by Fakhri Alauddin on 08 Januari 2019
*/
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class UpdateBiodata extends AppCompatActivity{
protected Cursor cursor;
DataHelper dbHelper;
Button ton1, ton2;
EditText text1, text2, text3, text4, text5, text6, text7;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.update_biodata);
dbHelper = new DataHelper(this);
text1 = (EditText) findViewById(R.id.editText1);
text2 = (EditText) findViewById(R.id.editText2);
text3 = (EditText) findViewById(R.id.editText3);
text4 = (EditText) findViewById(R.id.editText4);
text5 = (EditText) findViewById(R.id.editText5);
text6 = (EditText) findViewById(R.id.editText6);
text7 = (EditText) findViewById(R.id.editText7);
SQLiteDatabase db = dbHelper.getReadableDatabase();
cursor = db.rawQuery("SELECT * FROM biodatapekerja WHERE nama = '" +
getIntent().getStringExtra("nama") + "'",null);
cursor.moveToFirst();
if (cursor.getCount()>0)
{
cursor.moveToPosition(0);
text1.setText(cursor.getString(0).toString());
text2.setText(cursor.getString(1).toString());
text3.setText(cursor.getString(2).toString());
text4.setText(cursor.getString(3).toString());
text5.setText(cursor.getString(4).toString());
text6.setText(cursor.getString(5).toString());
text7.setText(cursor.getString(6).toString());
}
ton1 = (Button) findViewById(R.id.button1);
ton2 = (Button) findViewById(R.id.button2);
// daftarkan even onClick pada btnSimpan
ton1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
SQLiteDatabase db = dbHelper.getWritableDatabase();
db.execSQL("update biodatapekerja set nama='"+
text2.getText().toString()+"', tgl='" +
text3.getText().toString()+"', jk='"+
text4.getText().toString()+"', alamat='" +
text5.getText().toString()+"' jabatan='" +
text6.getText().toString()+"' golongan='" +
text7.getText().toString()+"' where no='" +
text1.getText().toString()+"'");
Toast.makeText(getApplicationContext(), "Berhasil", Toast.LENGTH_LONG).show();
MainActivity.ma.RefrestList();
finish();
}
});
ton2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
finish();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
/**
* Created by Fakhri Alauddin on 08 Januari 2019
*/
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class UpdateBiodata extends AppCompatActivity{
protected Cursor cursor;
DataHelper dbHelper;
Button ton1, ton2;
EditText text1, text2, text3, text4, text5, text6, text7;
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.update_biodata);
dbHelper = new DataHelper(this);
text1 = (EditText) findViewById(R.id.editText1);
text2 = (EditText) findViewById(R.id.editText2);
text3 = (EditText) findViewById(R.id.editText3);
text4 = (EditText) findViewById(R.id.editText4);
text5 = (EditText) findViewById(R.id.editText5);
text6 = (EditText) findViewById(R.id.editText6);
text7 = (EditText) findViewById(R.id.editText7);
SQLiteDatabase db = dbHelper.getReadableDatabase();
cursor = db.rawQuery("SELECT * FROM biodatapekerja WHERE nama = '" +
getIntent().getStringExtra("nama") + "'",null);
cursor.moveToFirst();
if (cursor.getCount()>0)
{
cursor.moveToPosition(0);
text1.setText(cursor.getString(0).toString());
text2.setText(cursor.getString(1).toString());
text3.setText(cursor.getString(2).toString());
text4.setText(cursor.getString(3).toString());
text5.setText(cursor.getString(4).toString());
text6.setText(cursor.getString(5).toString());
text7.setText(cursor.getString(6).toString());
}
ton1 = (Button) findViewById(R.id.button1);
ton2 = (Button) findViewById(R.id.button2);
// daftarkan even onClick pada btnSimpan
ton1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
SQLiteDatabase db = dbHelper.getWritableDatabase();
db.execSQL("update biodatapekerja set nama='"+
text2.getText().toString()+"', tgl='" +
text3.getText().toString()+"', jk='"+
text4.getText().toString()+"', alamat='" +
text5.getText().toString()+"' jabatan='" +
text6.getText().toString()+"' golongan='" +
text7.getText().toString()+"' where no='" +
text1.getText().toString()+"'");
Toast.makeText(getApplicationContext(), "Berhasil", Toast.LENGTH_LONG).show();
MainActivity.ma.RefrestList();
finish();
}
});
ton2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
finish();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Source Code update_biodata.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".UpdateBiodata"
android:background="#FFCCFFCC">
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1" >
<requestFocus />
</EditText>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="NIK"/>
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/textView2"
android:layout_below="@+id/textView2">
</EditText>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView2"
android:layout_alignLeft="@+id/editText1"
android:layout_below="@+id/editText1"
android:layout_marginTop="10dp"
android:text="Nama Karyawan" />
<EditText
android:id="@+id/editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_below="@+id/textView3" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText2"
android:layout_below="@+id/editText2"
android:layout_marginTop="10dp"
android:text="Tanggal Lahir" />
<EditText
android:id="@+id/editText4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView4"
android:layout_below="@+id/textView4" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText3"
android:layout_below="@+id/editText3"
android:layout_marginTop="10dp"
android:text="Jenis Kelamin" />
<EditText
android:id="@+id/editText5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView5"
android:layout_below="@+id/textView5" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText4"
android:layout_below="@+id/editText4"
android:layout_marginTop="10dp"
android:text="Alamat" />
<EditText
android:id="@+id/editText6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView6"
android:layout_below="@+id/textView6" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText5"
android:layout_below="@+id/editText5"
android:layout_marginTop="10dp"
android:text="Jabatan" />
<EditText
android:id="@+id/editText7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView7"
android:layout_below="@+id/textView7" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText6"
android:layout_below="@+id/editText6"
android:layout_marginTop="10dp"
android:text="Golongan" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/editText7"
android:layout_alignParentBottom="true"
android:layout_marginLeft="285dp"
android:layout_marginBottom="6dp"
android:text="Update" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="12dp"
android:layout_marginLeft="-77dp"
android:layout_marginBottom="6dp"
android:layout_toRightOf="@+id/textView4"
android:text="Back"
android:layout_alignParentLeft="true" />
</RelativeLayout>
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".UpdateBiodata"
android:background="#FFCCFFCC">
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1" >
<requestFocus />
</EditText>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="NIK"/>
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/textView2"
android:layout_below="@+id/textView2">
</EditText>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView2"
android:layout_alignLeft="@+id/editText1"
android:layout_below="@+id/editText1"
android:layout_marginTop="10dp"
android:text="Nama Karyawan" />
<EditText
android:id="@+id/editText3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_below="@+id/textView3" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText2"
android:layout_below="@+id/editText2"
android:layout_marginTop="10dp"
android:text="Tanggal Lahir" />
<EditText
android:id="@+id/editText4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView4"
android:layout_below="@+id/textView4" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText3"
android:layout_below="@+id/editText3"
android:layout_marginTop="10dp"
android:text="Jenis Kelamin" />
<EditText
android:id="@+id/editText5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView5"
android:layout_below="@+id/textView5" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText4"
android:layout_below="@+id/editText4"
android:layout_marginTop="10dp"
android:text="Alamat" />
<EditText
android:id="@+id/editText6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView6"
android:layout_below="@+id/textView6" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText5"
android:layout_below="@+id/editText5"
android:layout_marginTop="10dp"
android:text="Jabatan" />
<EditText
android:id="@+id/editText7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView7"
android:layout_below="@+id/textView7" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText6"
android:layout_below="@+id/editText6"
android:layout_marginTop="10dp"
android:text="Golongan" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/editText7"
android:layout_alignParentBottom="true"
android:layout_marginLeft="285dp"
android:layout_marginBottom="6dp"
android:text="Update" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="12dp"
android:layout_marginLeft="-77dp"
android:layout_marginBottom="6dp"
android:layout_toRightOf="@+id/textView4"
android:text="Back"
android:layout_alignParentLeft="true" />
</RelativeLayout>
C. Menjalankan Program Aplikasi
Kurang lebih tampilan nya adalah sebagai berkut:
![]() | ||
Tampilan Awal
|
![]() |
| Tampilan Upadate Biodata |
![]() |
| Tampilan Lihat Biodata |
![]() |
| Tampilan Setelah Menambah Data Karyawan |
![]() |
| Foto Lembar Jawaban |






Komentar
Posting Komentar