Newest Post
// Posted by :kelvin
// On :Rabu, 08 Januari 2020
Aplikasi Daftar Handphone dengan listview menggunakan sqlite aplikasi
ini saya buat menggunakan android studio. dimana ada 3 activity yang
pertama form dari Login dan yang ke 2 ada form Register dan yang ke 3
adalah listviewnya. disini dibagian form loginnya menggunakan database
yaitu sqlite setelah itu kita masuk ke listview handphone.
Judul Project Dan Penjelasan
langkah - langkah membuat project baru di android studio
- Buka Aplikasi Android Studio
- Buat Project baru dengan memilih template Empty kemudian klik Next
Pemilihan Template |
3. Masukan Nama, Tentukan Lokasi Penyimpanan, Lalu Pilih Minimum API Level. kemudian Finish
Menentukan Nama |
4. Membuat DatabaseHelper
DataBaseHelper |
package com.example.kelvinn;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DatabaseHelper extends SQLiteOpenHelper{
public static final String DATABASE_NAME ="register.db";
public static final String TABLE_NAME ="registeruser";
public static final String COL_1 ="ID";
public static final String COL_2 ="username";
public static final String COL_3 ="password";
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL("CREATE TABLE registeruser (ID INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT, password TEXT)");
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
sqLiteDatabase.execSQL(" DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(sqLiteDatabase);
}
public long addUser(String user, String password){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put("username",user);
contentValues.put("password",password);
long res = db.insert("registeruser",null,contentValues);
db.close();
return res;
}
public boolean checkUser(String username, String password){
String[] columns = { COL_1 };
SQLiteDatabase db = getReadableDatabase();
String selection = COL_2 + "=?" + " and " + COL_3 + "=?";
String[] selectionArgs = { username, password };
Cursor cursor = db.query(TABLE_NAME,columns,selection,selectionArgs,null,null,null);
int count = cursor.getCount();
cursor.close();
db.close();
if(count>0)
return true;
else
return false;
}
}
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DatabaseHelper extends SQLiteOpenHelper{
public static final String DATABASE_NAME ="register.db";
public static final String TABLE_NAME ="registeruser";
public static final String COL_1 ="ID";
public static final String COL_2 ="username";
public static final String COL_3 ="password";
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, 1);
}
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
sqLiteDatabase.execSQL("CREATE TABLE registeruser (ID INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT, password TEXT)");
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
sqLiteDatabase.execSQL(" DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(sqLiteDatabase);
}
public long addUser(String user, String password){
SQLiteDatabase db = this.getWritableDatabase();
ContentValues contentValues = new ContentValues();
contentValues.put("username",user);
contentValues.put("password",password);
long res = db.insert("registeruser",null,contentValues);
db.close();
return res;
}
public boolean checkUser(String username, String password){
String[] columns = { COL_1 };
SQLiteDatabase db = getReadableDatabase();
String selection = COL_2 + "=?" + " and " + COL_3 + "=?";
String[] selectionArgs = { username, password };
Cursor cursor = db.query(TABLE_NAME,columns,selection,selectionArgs,null,null,null);
int count = cursor.getCount();
cursor.close();
db.close();
if(count>0)
return true;
else
return false;
}
}
5. Membuat Login.Java
Login |
package com.example.kelvinn;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class LoginActivity extends AppCompatActivity {
EditText mTextUsername;
EditText mTextPassword;
Button mButtonLogin;
TextView mTextViewRegister;
DatabaseHelper db;
ViewGroup progressView;
protected boolean isProgressShowing = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
db = new DatabaseHelper(this);
mTextUsername = (EditText)findViewById(R.id.edittext_username);
mTextPassword = (EditText)findViewById(R.id.edittext_password);
mButtonLogin = (Button)findViewById(R.id.button_login);
mTextViewRegister = (TextView)findViewById(R.id.textview_register);
mTextViewRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent registerIntent = new Intent(LoginActivity.this,RegisterActivity.class);
startActivity(registerIntent);
}
});
mButtonLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String user = mTextUsername.getText().toString().trim();
String pwd = mTextPassword.getText().toString().trim();
Boolean res = db.checkUser(user, pwd);
if(res == true)
{
Intent HomePage = new Intent(LoginActivity.this,MainActivity.class);
startActivity(HomePage);
}
else
{
Toast.makeText(LoginActivity.this,"Login Error",Toast.LENGTH_SHORT).show();
}
}
});
}
public void showProgressingView() {
// if (!isProgressShowing) {
//View view=findViewById(R.id.progressBar1);
// view.bringToFront();
// }
}
public void hideProgressingView() {
View v = this.findViewById(android.R.id.content).getRootView();
ViewGroup viewGroup = (ViewGroup) v;
viewGroup.removeView(progressView);
isProgressShowing = false;
}
}
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class LoginActivity extends AppCompatActivity {
EditText mTextUsername;
EditText mTextPassword;
Button mButtonLogin;
TextView mTextViewRegister;
DatabaseHelper db;
ViewGroup progressView;
protected boolean isProgressShowing = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
db = new DatabaseHelper(this);
mTextUsername = (EditText)findViewById(R.id.edittext_username);
mTextPassword = (EditText)findViewById(R.id.edittext_password);
mButtonLogin = (Button)findViewById(R.id.button_login);
mTextViewRegister = (TextView)findViewById(R.id.textview_register);
mTextViewRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent registerIntent = new Intent(LoginActivity.this,RegisterActivity.class);
startActivity(registerIntent);
}
});
mButtonLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String user = mTextUsername.getText().toString().trim();
String pwd = mTextPassword.getText().toString().trim();
Boolean res = db.checkUser(user, pwd);
if(res == true)
{
Intent HomePage = new Intent(LoginActivity.this,MainActivity.class);
startActivity(HomePage);
}
else
{
Toast.makeText(LoginActivity.this,"Login Error",Toast.LENGTH_SHORT).show();
}
}
});
}
public void showProgressingView() {
// if (!isProgressShowing) {
//View view=findViewById(R.id.progressBar1);
// view.bringToFront();
// }
}
public void hideProgressingView() {
View v = this.findViewById(android.R.id.content).getRootView();
ViewGroup viewGroup = (ViewGroup) v;
viewGroup.removeView(progressView);
isProgressShowing = false;
}
}
5.2 Membuat Login.XML
5.3 Source Code Login.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="LoginActivity"
android:orientation="vertical"
android:id="@+id/container"
android:background="#123456"
android:gravity="center_horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="127dp"
android:layout_marginTop="50dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="@android:color/transparent"
android:gravity="center_horizontal"
android:orientation="vertical">
<EditText
android:id="@+id/edittext_username"
android:layout_width="190dp"
android:layout_height="40dp"
android:layout_marginTop="10dp"
android:background="#ffffff"
android:hint="@string/username"
android:paddingLeft="2dp" />
<EditText
android:id="@+id/edittext_password"
android:layout_width="190dp"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:background="#ffffff"
android:inputType="textPassword"
android:hint="@string/password" />
</LinearLayout>
<Button
android:id="@+id/button_login"
android:layout_width="190dp"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:background="#04ea00"
android:textColor="#ffffff"
android:text="@string/login"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Sudah Punya Akun?"
android:textColor="#ffffff" />
<TextView
android:id="@+id/textview_register"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:paddingLeft="10dp"
android:text="Daftar"
android:textColor="#04ea00"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<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="LoginActivity"
android:orientation="vertical"
android:id="@+id/container"
android:background="#123456"
android:gravity="center_horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="127dp"
android:layout_marginTop="50dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="@android:color/transparent"
android:gravity="center_horizontal"
android:orientation="vertical">
<EditText
android:id="@+id/edittext_username"
android:layout_width="190dp"
android:layout_height="40dp"
android:layout_marginTop="10dp"
android:background="#ffffff"
android:hint="@string/username"
android:paddingLeft="2dp" />
<EditText
android:id="@+id/edittext_password"
android:layout_width="190dp"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:background="#ffffff"
android:inputType="textPassword"
android:hint="@string/password" />
</LinearLayout>
<Button
android:id="@+id/button_login"
android:layout_width="190dp"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:background="#04ea00"
android:textColor="#ffffff"
android:text="@string/login"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Sudah Punya Akun?"
android:textColor="#ffffff" />
<TextView
android:id="@+id/textview_register"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:paddingLeft="10dp"
android:text="Daftar"
android:textColor="#04ea00"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
6. Membuat Register.Java
6.1 Source Code Register.Java
package com.example.kelvinn;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class RegisterActivity extends AppCompatActivity {
DatabaseHelper db;
EditText mTextUsername;
EditText mTextPassword;
EditText mTextCnfPassword;
Button mButtonRegister;
TextView mTextViewLogin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
db = new DatabaseHelper(this);
mTextUsername = (EditText)findViewById(R.id.edittext_username);
mTextPassword = (EditText)findViewById(R.id.edittext_password);
mTextCnfPassword = (EditText)findViewById(R.id.edittext_cnf_password);
mButtonRegister = (Button)findViewById(R.id.button_register);
mTextViewLogin = (TextView)findViewById(R.id.textview_login);
mTextViewLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent LoginIntent = new Intent(RegisterActivity.this,LoginActivity.class);
startActivity(LoginIntent);
}
});
mButtonRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String user = mTextUsername.getText().toString().trim();
String pwd = mTextPassword.getText().toString().trim();
String cnf_pwd = mTextCnfPassword.getText().toString().trim();
if(pwd.equals(cnf_pwd)){
long val = db.addUser(user,pwd);
if(val > 0){
Toast.makeText(RegisterActivity.this,"Berhasil Mendaftar",Toast.LENGTH_SHORT).show();
Intent moveToLogin = new Intent(RegisterActivity.this,LoginActivity.class);
startActivity(moveToLogin);
}
else{
Toast.makeText(RegisterActivity.this,"Registeration Error",Toast.LENGTH_SHORT).show();
}
}
else{
Toast.makeText(RegisterActivity.this,"Password is not matching",Toast.LENGTH_SHORT).show();
}
}
});
}
}
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class RegisterActivity extends AppCompatActivity {
DatabaseHelper db;
EditText mTextUsername;
EditText mTextPassword;
EditText mTextCnfPassword;
Button mButtonRegister;
TextView mTextViewLogin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
db = new DatabaseHelper(this);
mTextUsername = (EditText)findViewById(R.id.edittext_username);
mTextPassword = (EditText)findViewById(R.id.edittext_password);
mTextCnfPassword = (EditText)findViewById(R.id.edittext_cnf_password);
mButtonRegister = (Button)findViewById(R.id.button_register);
mTextViewLogin = (TextView)findViewById(R.id.textview_login);
mTextViewLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent LoginIntent = new Intent(RegisterActivity.this,LoginActivity.class);
startActivity(LoginIntent);
}
});
mButtonRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String user = mTextUsername.getText().toString().trim();
String pwd = mTextPassword.getText().toString().trim();
String cnf_pwd = mTextCnfPassword.getText().toString().trim();
if(pwd.equals(cnf_pwd)){
long val = db.addUser(user,pwd);
if(val > 0){
Toast.makeText(RegisterActivity.this,"Berhasil Mendaftar",Toast.LENGTH_SHORT).show();
Intent moveToLogin = new Intent(RegisterActivity.this,LoginActivity.class);
startActivity(moveToLogin);
}
else{
Toast.makeText(RegisterActivity.this,"Registeration Error",Toast.LENGTH_SHORT).show();
}
}
else{
Toast.makeText(RegisterActivity.this,"Password is not matching",Toast.LENGTH_SHORT).show();
}
}
});
}
}
6.2 Membuat Register.XML
6.3 Source Code Register.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="@color/colorPrimaryDark"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context="RegisterActivity">
<ImageView
android:layout_width="wrap_content"
android:layout_height="127dp"
android:layout_marginTop="50dp" />
<EditText
android:id="@+id/edittext_username"
android:layout_width="206dp"
android:layout_height="40dp"
android:layout_marginTop="10dp"
android:background="#ffffff"
android:hint="UserName"
android:paddingLeft="2dp" />
<EditText
android:id="@+id/edittext_password"
android:layout_width="206dp"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:background="#ffffff"
android:hint="@string/password"
android:inputType="textPassword" />
android:hint="@string/password"/>
<EditText
android:id="@+id/edittext_cnf_password"
android:layout_width="206dp"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:background="#ffffff"
android:hint="@string/password"
android:inputType="textPassword" />
android:hint="@string/confirm_password"/>
<Button
android:id="@+id/button_register"
android:layout_width="206dp"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:background="#04ea00"
android:text="Daftar"
android:textColor="#ffffff" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Sudah Punya Akun?"
android:textColor="#ffffff" />
<TextView
android:id="@+id/textview_login"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:paddingLeft="10dp"
android:text="@string/login"
android:textColor="#04ea00"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<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="@color/colorPrimaryDark"
android:gravity="center_horizontal"
android:orientation="vertical"
tools:context="RegisterActivity">
<ImageView
android:layout_width="wrap_content"
android:layout_height="127dp"
android:layout_marginTop="50dp" />
<EditText
android:id="@+id/edittext_username"
android:layout_width="206dp"
android:layout_height="40dp"
android:layout_marginTop="10dp"
android:background="#ffffff"
android:hint="UserName"
android:paddingLeft="2dp" />
<EditText
android:id="@+id/edittext_password"
android:layout_width="206dp"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:background="#ffffff"
android:hint="@string/password"
android:inputType="textPassword" />
android:hint="@string/password"/>
<EditText
android:id="@+id/edittext_cnf_password"
android:layout_width="206dp"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:background="#ffffff"
android:hint="@string/password"
android:inputType="textPassword" />
android:hint="@string/confirm_password"/>
<Button
android:id="@+id/button_register"
android:layout_width="206dp"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:background="#04ea00"
android:text="Daftar"
android:textColor="#ffffff" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Sudah Punya Akun?"
android:textColor="#ffffff" />
<TextView
android:id="@+id/textview_login"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:paddingLeft="10dp"
android:text="@string/login"
android:textColor="#04ea00"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
7.Membuat ListView.Java
7.1 Source Code ListView.Java
package com.example.kelvinn;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import java.util.ArrayList;
import java.util.HashMap;
public class MainActivity extends Activity {
protected ListView lv;
protected ListAdapter adapter;
SimpleAdapter Adapter;
HashMap<String, String> map;
ArrayList<HashMap<String, String>> mylist;
String[] Pil;
String[] Ltn;
String[] Gbr;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lv = (ListView) findViewById(R.id.lv);
Pil = new String[] {"Samsung", "Apple", "Huawei", "Vivo", "Xiaomi"};
Ltn = new String[] {"", "", "", "", ""};
Gbr = new String[] {Integer.toString(R.drawable.samsung),
Integer.toString(R.drawable.apple),
Integer.toString(R.drawable.huawei),
Integer.toString(R.drawable.vivo),
Integer.toString(R.drawable.xiaomi) };
mylist = new ArrayList<HashMap<String,String>>();
for (int i = 0; i < Pil.length; i++){
map = new HashMap<String, String>();
map.put("list", Pil[i]);
map.put("latin", Ltn[i]);
map.put("gbr", Gbr[i]);
mylist.add(map);
}
Adapter = new SimpleAdapter(this, mylist, R.layout.layout_isi_lv,
new String[] {"list", "latin", "gbr"}, new int[] {R.id.tv_nama, R.id.tv_ltn, R.id.imV});
lv.setAdapter(Adapter);
}
}
import android.app.Activity;
import android.os.Bundle;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import java.util.ArrayList;
import java.util.HashMap;
public class MainActivity extends Activity {
protected ListView lv;
protected ListAdapter adapter;
SimpleAdapter Adapter;
HashMap<String, String> map;
ArrayList<HashMap<String, String>> mylist;
String[] Pil;
String[] Ltn;
String[] Gbr;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
lv = (ListView) findViewById(R.id.lv);
Pil = new String[] {"Samsung", "Apple", "Huawei", "Vivo", "Xiaomi"};
Ltn = new String[] {"", "", "", "", ""};
Gbr = new String[] {Integer.toString(R.drawable.samsung),
Integer.toString(R.drawable.apple),
Integer.toString(R.drawable.huawei),
Integer.toString(R.drawable.vivo),
Integer.toString(R.drawable.xiaomi) };
mylist = new ArrayList<HashMap<String,String>>();
for (int i = 0; i < Pil.length; i++){
map = new HashMap<String, String>();
map.put("list", Pil[i]);
map.put("latin", Ltn[i]);
map.put("gbr", Gbr[i]);
mylist.add(map);
}
Adapter = new SimpleAdapter(this, mylist, R.layout.layout_isi_lv,
new String[] {"list", "latin", "gbr"}, new int[] {R.id.tv_nama, R.id.tv_ltn, R.id.imV});
lv.setAdapter(Adapter);
}
}
7.2 Membuat Layout Dari Listview
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ListView
android:id="@+id/lv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
></ListView>
</LinearLayout>
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ListView
android:id="@+id/lv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
></ListView>
</LinearLayout>
8. Membuat Layout_lv.XML
8.1 Source Code Layout_lv.XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
/>
<TextView
android:id="@+id/tv_nama"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/imV"
android:text="TextView"
android:textColor="#F80606"
android:textSize="10pt"
/>
<TextView
android:id="@+id/tv_ltn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tv_nama"
android:layout_below="@+id/tv_nama"
android:text="TextView"
android:textColor="#02808f"
/>
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
/>
<TextView
android:id="@+id/tv_nama"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/imV"
android:text="TextView"
android:textColor="#F80606"
android:textSize="10pt"
/>
<TextView
android:id="@+id/tv_ltn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/tv_nama"
android:layout_below="@+id/tv_nama"
android:text="TextView"
android:textColor="#02808f"
/>
</RelativeLayout>
maka sudah selesai untuk pembuatan aplikasi Daftar Hp Menggunakan Sqlite. Sekarang kita akan masuk ke tahap uji coba atau kita coba Run Aplikasinya.
Yang Pertama Kita masuk Ke form Login, sebelumnya kita harus daftar terlebih dahulu.
Dan dibawah ini adalah form untuk Daftar Atau register untuk masuk ke aplikasi
Setelah sudah daftar kita akan login ke aplikasinya. dan dibawah ini adalah tampilan setelah login
Berikut Adalah Video Hasil Running dari aplikasinya..
Sekian penjelasan dari aplikasi daftar handphone menggunakan sqlite. sekiranya ada pertanyaan silakan isi di kolom komentar.. Terimakasih GBU... :)
- Back to Home »
- UAS »
- Aplikasi Daftar Handphone dengan listview menggunakan sqlite