1. Search.java - Implementasi Algoritma Pencocokan String Boyer – Moore Dalam Pembuatan Contact Manager Pada Platform Android

LISTING PROGRAM

1. Search.java

  package

  id.mego;

  import

  java.util.HashMap;

  import

  java.util.List;

  import java.util.ArrayList; import java.util.Map; public class Search {

  public static List<Integer> match(String pattern, String text) { List<Integer> matches = new ArrayList<Integer>();

  // pecocokan panjang pattern (n) dengan panjang text (m) int m = text.length(); int n = pattern.length(); //proses pencocokan pattern dari kanan ke kiri dan proses sebelum Bad Character //dengan mencari posisi paling kanan dari semua karakter dalam pattern: Map<Character, Integer> rightMostIndexes =

  preprocessForBadCharacterShift(pattern);

  //mensejajarkan p dan t mulai dari indek 0 yaitu : awal teks = awal pattern //posisi 0 di cocokan dari awal pattern //pencocokan karakter akhir sampai awal int alignedAt = 0; while (alignedAt + (n - 1) < m) {

  //Pada setiap posisi sejajar, kita memindai pattern dari kanan ke kiri, membandingkan karakter //sejajar pada posisi saat ini dalam teks (t) dan pada posisi saat ini dalam pattern (p)

  for (int indexInPattern = n - 1; indexInPattern >= 0;

  indexInPattern--) { int indexInText = alignedAt + indexInPattern; char x = text.charAt(indexInText); char y = pattern.charAt(indexInPattern); if (indexInText >= m) break; //kasus ketidakcocokan, kita melakukan pergeseran: if (x != y) { //Pertama-tama kita mengambil paling kanan indeks ketidakcocokan teks-karakter dalam pattern Integer r = rightMostIndexes.get(x); //Jika karakter ketidakcocokan dalam teks tidak dalam pattern kita bisa menggeser sampai //kita sejajar di belakang mismatch-posisi, //hal ini akan mengakibatkan beberapa karakter pernah diperiksa: if (r == null) { alignedAt = indexInText + 1; } //kita menggeser pattern ke kanan sampai paling kanan dari x dalam pattern posisi mismatch dalam teks //(pergeseran ini adalah pergeseran ke depan, yaitu ke kanan),

  else { int shift = indexInText - (alignedAt + r); alignedAt += shift > 0 ? shift : 1; } break; } //Jika karakter macth gerer pencocokan dari kanan ke kiri, //kita mencocokan karakter berikutnya dalam teks. else if (indexInPattern == 0) { matches.add(alignedAt); alignedAt++; } } } return matches; } //Untuk masing-masing karakter dalam pattern kita menyimpan hasil pencocokan yang paling kanan private static Map<Character, Integer> preprocessForBadCharacterShift( String pattern) { Map<Character, Integer> map = new HashMap<Character, Integer>(); for (int i = pattern.length() - 1; i >= 0; i--) { char c = pattern.charAt(i); if (!map.containsKey(c)) map.put(c, i); } return map; } }

2. MainActivity.java

  package

  id.mego;

  import

  android.os.Bundle;

  import

  android.support.v4.widget.DrawerLayout;

  import android.view.View; import

  android.view.View.OnClickListener;

  import

  android.widget.ImageView;

  public

  class MainActivity extends android.support.v4.app.FragmentActivity implements OnClickListener { private boolean draweropened = false; protected void onCreate(Bundle savedInstanceState) {

  super

  .onCreate(savedInstanceState); setContentView(R.layout.navigationdrawer); if(getSupportFragmentManager().findFragmentByTag(ContactFragment.TAG) == null) getSupportFragmentManager().beginTransaction().add(R.id.container,

  new

  ContactFragment(), ContactFragment.TAG).commit(); }

  public void onClick(View v) { // TODO Auto-generated method stub DrawerLayout drawer = (DrawerLayout)findViewById(R.id.list);

  if

  (draweropened) drawer.closeDrawer(findViewById(R.id.navigationdrawer));

  else

  drawer.openDrawer(findViewById(R.id.navigationdrawer)); draweropened = !draweropened; } }

3. NavigationDrawerFragment.java

  package id.mego; import

  android.content.Intent;

  import android.os.Bundle; import

  android.view.LayoutInflater;

  import

  android.view.View;

  import android.widget.ArrayAdapter; import

  android.widget.ImageView;

  import

  android.widget.TextView;

  public

  class NavigationDrawerFragment extends android.support.v4.app.ListFragment { public void onViewCreated(View view, Bundle bundle) {

  super

  .onViewCreated(view, bundle); getListView().setBackgroundColor(getResources().getColor(R.color.whit

  e));

  setListAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, new String[] { "Help", "About" }) {

  private

  int[] imgResource = { R.drawable.ic_help, R.drawable.ic_about };

  public

  View getView(int position, View convertView, android.view.ViewGroup root) {

  if

  (convertView == null) convertView = LayoutInflater.from(getActivity()).inflate(R.layout.item_navdrawer, root, false);

  ((TextView) convertView.findViewById(R.id.text_list)).setText(getItem(position)); ((ImageView) convertView.findViewById(R.id.ic_list)).setImageResource(imgResource[p osition]);

  return

  convertView; }

  }); } public void onListItemClick(android.widget.ListView listView, View v,

  int position, long id) { switch

  (position) {

  case 0:

  startActivity(new Intent(getActivity(), Help.class));

  break

  case

  1: startActivity(new Intent(getActivity(), About.class));

  break ;

  } } }

4. ContactFragment.java

  import

  java.util.ArrayList;

  import

  java.util.List;

  import id.mego.adapter.Adapter; import

  id.mego.database.ContactDB;

  import

  id.mego.entity.Contact;

  import android.content.Intent; import

  android.os.Bundle;

  import

  android.view.LayoutInflater;

  import android.view.Menu; import

  android.view.MenuInflater;

  import

  android.view.MenuItem;

  import android.view.View; import

  android.view.ViewGroup;

  import

  android.widget.AdapterView;

  import android.widget.AdapterView.OnItemClickListener; import

  android.widget.ListAdapter;

  import

  android.widget.ListView;

  import android.widget.SearchView; import

  android.widget.Toast;

  public class ContactFragment extends android.support.v4.app.Fragment implements

  OnItemClickListener { public static String TAG = "ContactFragment"; private ListView lv; private ContactDB db; private Adapter adapter; public View onCreateView(LayoutInflater inflater, ViewGroup root, Bundle savedInstanceState) {

  View view = inflater.inflate(R.layout.activity_main, root,

  false

  ); db = ContactDB.getInstance(getActivity()); lv = (ListView) view.findViewById(R.id.listview_contact); lv.setEmptyView(view.findViewById(R.id.empty));

  if (db.isContactHasData()) {

  List<Contact> contacts = db.getAllContact(); adapter = new Adapter(getActivity(), contacts); lv.setAdapter(adapter);

  } lv.setOnItemClickListener(this); setHasOptionsMenu(true);

  return

  view; } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { SearchView search = (SearchView) menu.findItem(R.id.action_search).getActionView(); search.setOnQueryTextListener(new

  SearchView.OnQueryTextListener() {

  public

  boolean onQueryTextSubmit(String query) {

  return false;

  }

  public boolean onQueryTextChange(String newText) { if

  (newText.equals("")) lv.setAdapter(new Adapter(getActivity(), db.getAllContact()));

  else

  { ArrayList<Contact> found = new

  ArrayList<Contact>();

  for (int i = 0; i < adapter.getCount(); i++) {

  Contact data = (Contact) adapter.getItem(i);

  if (!Search.match(newText.toUpperCase(),

  data.getNama().toUpperCase()).isEmpty()) found.add(data); } lv.setAdapter(new Adapter(getActivity(), found));

  }

  return

  false; }

  }); } @Override public boolean onOptionsItemSelected(MenuItem item) {

  switch (item.getItemId()) { case R.id.add:

  Toast.makeText(getActivity(), "add contact", Toast.LENGTH_SHORT).show(); startActivity(new Intent(getActivity(), Add.class));

  return

  true;

  default : return

  super.onOptionsItemSelected(item); }

  } @Override public void onItemClick(AdapterView<?> adapterView, View arg1, int position, long arg3) {

  Bundle b = new Bundle(); ListAdapter adapter = lv.getAdapter(); b.putInt("id", ((Contact) adapter.getItem(position)).getId()); b.putString("nama", ((Contact) adapter.getItem(position)).getNama()); b.putString("phone", ((Contact) adapter.getItem(position)).getNumber()); b.putString("email", ((Contact) adapter.getItem(position)).getEmail()); b.putString("address", ((Contact) adapter.getItem(position)).getAddress()); b.putString("note", ((Contact) adapter.getItem(position)).getNote()); b.putString("pict", ((Contact) adapter.getItem(position)).getPict()); Intent i = new Intent(getActivity(), Detail.class); i.putExtras(b); startActivity(i);

  } }

5. Add.java

  package

  id.mego;

  import id.mego.database.ContactDB; import

  id.mego.entity.Contact;

  import

  id.mego.MainActivity;

  import id.mego.R; import

  android.content.Intent;

  import

  android.net.Uri;

  import android.os.Bundle; import

  android.support.v7.app.ActionBarActivity;

  import

  android.text.TextUtils;

  import android.view.View; import

  android.view.View.OnClickListener;

  import

  android.widget.Button;

  import android.widget.EditText; import

  android.widget.ImageView;

  import

  android.widget.Toast;

  public

  class Add extends ActionBarActivity implements OnClickListener { private EditText nama, email, phone, address, note; private Button cancel, done; private ContactDB db; private ImageView pict; private String imgPath = ""; @Override protected void onCreate(Bundle savedInstanceState) {

  super .onCreate(savedInstanceState);

  setContentView(R.layout.activity_add); db = ContactDB.getInstance(this); nama = (EditText) findViewById(R.id.input_name); email = (EditText) findViewById(R.id.input_email); phone = (EditText) findViewById(R.id.input_phone); address = (EditText) findViewById(R.id.input_alamat); note = (EditText) findViewById(R.id.input_catatan); cancel = (Button) findViewById(R.id.btn_cancel); done = (Button) findViewById(R.id.btn_done); pict = (ImageView) findViewById(R.id.input_image); pict.setOnClickListener(this); cancel.setOnClickListener(this); done.setOnClickListener(this); }

  @Override public void onClick(View v)

  if

  (v == done) {

  if (!TextUtils.isEmpty(nama.getText().toString()) &&

  !TextUtils.isEmpty(phone.getText().toString()) && !TextUtils.isEmpty(email.getText().toString())

  && !TextUtils.isEmpty(address.getText().toString()) && !TextUtils.isEmpty(note.getText().toString())) { String name = nama.getText().toString().toLowerCase(); name = String.valueOf(name.charAt(0)).toUpperCase()

  • name.substring(1, name.length()); db.addContact(new Contact( name, phone.getText().toString(), email.getText().toString(), address.getText().toString(), note.getText().toString(), imgPath)); startActivity(new Intent(this, MainActivity.class)); finish();

  } else {

  Toast.makeText(this, "Lengkapi Data", Toast.LENGTH_SHORT) .show();

  } }

  else if (v == cancel)

  { startActivity(new Intent(this, MainActivity.class)); finish();

  }

  else if(v == pict) {

  Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, 1);

  } } @Override public void onBackPressed() { // TODO Auto-generated method stub super.onBackPressed(); finish(); startActivity(new Intent(this, MainActivity.class)); } public void onActivityResult(int requestCode, int resultCode, Intent data) {

  if

  (requestCode == 1 && resultCode == RESULT_OK) { String[] projection = { android.provider.MediaStore.Images.Media.DATA }; android.database.Cursor c = getContentResolver().query(data.getData(), projection, "", null, "");

  if

  (c.moveToFirst()) { imgPath = c.getString(c.getColumnIndex(projection[0])); pict.setImageURI(Uri.parse(imgPath));

  } }

  } }

6. Edit.java

  import id.mego.database.ContactDB; import

  id.mego.entity.Contact;

  import

  android.net.Uri;

  import android.os.Bundle; import

  android.content.Intent;

  import

  android.support.v7.app.ActionBarActivity;

  import android.view.View; import

  android.view.View.OnClickListener;

  import

  android.widget.Button;

  import android.widget.EditText; import

  android.widget.ImageView;

  

public class Edit extends ActionBarActivity implements OnClickListener

  { private EditText nama, email, phone, address, note; private Button cancel, done; private ContactDB db; private ImageView pict; private String imgPath = ""; private int id; @Override protected void onCreate(Bundle savedInstanceState) {

  super .onCreate(savedInstanceState);

  setContentView(R.layout.activity_edit); getSupportActionBar().setTitle("Edit Contact"); db = ContactDB.getInstance(this); nama = (EditText) findViewById(R.id.edit_name); email = (EditText) findViewById(R.id.edit_email); phone = (EditText) findViewById(R.id.edit_phone); address = (EditText) findViewById(R.id.edit_alamat); note = (EditText) findViewById(R.id.edit_catatan); cancel = (Button) findViewById(R.id.btn_cancel); done = (Button) findViewById(R.id.btn_done); pict = (ImageView)findViewById(R.id.edit_image); Bundle b = getIntent().getExtras();

  if

  (b != null) { id = b.getInt("id"); nama.setText(b.getString("name")); phone.setText(b.getString("phone")); email.setText(b.getString("email")); address.setText(b.getString("address")); note.setText(b.getString("note"));

  if

  ((imgPath = b.getString("pict")).equals("")) pict.setImageResource(R.drawable.icon_user);

  else

  pict.setImageURI(Uri.parse(imgPath)); cancel.setOnClickListener(this); done.setOnClickListener(this);

  }} @Override public void onClick(View v) {

  if (v == done)

  { String name = nama.getText().toString().toLowerCase(); name = String.valueOf(name.charAt(0)).toUpperCase() + name.substring(1, name.length());

  Contact contact = new Contact( name, phone .getText().toString(), email.getText().toString(), address.getText().toString(), note.getText().toString(), imgPath); contact.setId(id); db.editContact(contact); startActivity(new Intent(this, MainActivity.class)); finish();

  } else if (v == cancel) { startActivity(new Intent(this, MainActivity.class)); finish();

  }

  else

  if(v == pict) { Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, 1);

  } } @Override public void onBackPressed() {

  // TODO Auto-generated method stub

  super .onBackPressed();

  startActivity(new Intent(this, MainActivity.class)); finish(); } public void onActivityResult(int requestCode, int resultCode, Intent data) {

  if (requestCode == 1 && resultCode == RESULT_OK) {

  String[] projection = { android.provider.MediaStore.Images.Media.DATA }; android.database.Cursor c = getContentResolver().query(data.getData(), projection, "", null, "");

  if

  (c.moveToFirst()) { imgPath = c.getString(c.getColumnIndex(projection[0])); pict.setImageURI(Uri.parse(imgPath));

  } }

  } }

7. Detail.java

  package

  import

  id.mego.database.ContactDB;

  import

  android.R.drawable;

  import

  android.app.AlertDialog;

  import android.content.DialogInterface; import android.content.Intent; import

  android.net.Uri;

  import android.os.Bundle; import

  android.support.v7.app.ActionBarActivity;

  import

  android.view.Menu;

  import android.view.MenuItem; import

  android.view.View;

  import

  android.view.View.OnClickListener;

  import android.widget.ImageView; import android.widget.TextView; public class Detail extends ActionBarActivity implements

  OnClickListener {

  private TextView phone, email, address, note; private int id; private

  ImageView call, btnEmail, pict,btnmessage;

  private String imgPath = ""; private ContactDB db;

  @Override protected void onCreate(Bundle savedInstanceState) {

  super .onCreate(savedInstanceState);

  setContentView(R.layout.activity_detail); db = ContactDB.getInstance(this); phone = (TextView) findViewById(R.id.txt_phone_number); email = (TextView) findViewById(R.id.txt_email); address = (TextView) findViewById(R.id.txt_alamat); note = (TextView) findViewById(R.id.txt_catatan); pict = (ImageView) findViewById(R.id.thumb_detail); call = (ImageView) findViewById(R.id.btn_call); btnEmail = (ImageView) findViewById(R.id.btn_email); btnmessage = (ImageView) findViewById(R.id.btn_message);

  Bundle b = getIntent().getExtras();

  if (b != null)

  { id = b.getInt("id"); phone.setText(b.getString("phone")); address.setText(b.getString("address")); note.setText(b.getString("note"));

  if

  ((imgPath = b.getString("pict")).equals("")) pict.setImageResource(R.drawable.icon_user);

  else

  pict.setImageURI(Uri.parse(imgPath)); getSupportActionBar().setTitle(b.getString("nama"));

  if

  (!b.getString("email").equals("null")) { email.setText(b.getString("email")); } else { email.setText("");

  } } call.setOnClickListener(this); btnmessage.setOnClickListener(this); btnEmail.setOnClickListener(this);

  :

  null ));

  Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email.getText().toString(),

  (!email.getText().toString().equals("")) {

  if

  (v == btnEmail) {

  if

  super.onOptionsItemSelected(item); } } @Override public void onClick(View v) {

  return

  return true; default

  } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.detail_contact, menu);

  R.id.action_delete: showSettingsAlert();

  return true; case

  Bundle b = new Bundle(); b.putInt("id", id); b.putString("name", getSupportActionBar().getTitle().toString()); b.putString("email", email.getText().toString()); b.putString("phone", phone.getText().toString()); b.putString("address", address.getText().toString()); b.putString("note", note.getText().toString()); b.putString("pict", imgPath); Intent i = new Intent(this, Edit.class); i.putExtras(b); startActivity(i); finish();

  case R.id.action_edit:

  (item.getItemId()) {

  switch

  true; } @Override public boolean onOptionsItemSelected(MenuItem item) {

  return

  startActivity(Intent

  .createChooser(emailIntent, "Send email...")); }

  }

  else if (v == call)

  { Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:" + phone.getText().toString())); startActivity(callIntent); }

  else if (v == btnmessage )

  { Intent smsIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", phone.getText().toString(),

  null

  )); startActivity(Intent .createChooser(smsIntent, "Send Message..."));

  } } private void showSettingsAlert() {

  AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setIcon(drawable.ic_menu_help); alert.setTitle("Delete"); alert.setMessage("Delete Contact"); alert.setPositiveButton("Yes", new

  DialogInterface.OnClickListener() { @Override

  

public void onClick(DialogInterface dialog, int which)

  { db.deleteContact(id); startActivity(new Intent(Detail.this,

  MainActivity.class)); finish(); }

  }); alert.setNegativeButton("No", new DialogInterface.OnClickListener() { @Override

  public

  void onClick(DialogInterface dialog, int which) { dialog.cancel(); }

  }); alert.show(); } @Override

  public void onBackPressed() {

  super .onBackPressed();

  startActivity(new Intent(Detail.this, MainActivity.class)); finish(); } }

  8. About.java package id.mego; import

  android.app.Activity;

  import android.os.Bundle; public class About extends Activity {

  @Override protected void onCreate(Bundle savedInstanceState) {

  super .onCreate(savedInstanceState);

  setContentView(R.layout.activity_about); } }

  9. Help.java package

  id.mego;

  import android.app.Activity; import

  android.os.Bundle;

  public

  class Help extends Activity { @Override protected void onCreate(Bundle savedInstanceState) {

  super

  .onCreate(savedInstanceState); setContentView(R.layout.activity_help); }}

  Actionnavigation.xml 10.

  <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <ImageButton android:id="@+id/navi" style="?android:attr/borderlessButtonStyle" android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/ic_drawer"/> <TextView android:id="@+id/teksnav" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Contact Manager" android:textColor="@color/white" android:textSize="17sp"

  </LinearLayout>

11. Activity_about.xml

  <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/textView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:layout_marginTop="5dp" android:text="IMPLEMENTASI ALGORITMA PENCOCOKAN STRING BOYER- MOORE DALAM PEMBUATAN CONTACT MANAGER PADA PLATFORM ANDROID" /> <TextView android:id="@+id/textView2" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:layout_marginTop="5dp" android:text="SKRIPSI"/> <TextView android:id="@+id/textView3" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:layout_marginTop="5dp" android:text="MEGO SUNTORO"/> <TextView android:id="@+id/textView4" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:layout_marginTop="5dp" android:text="101401004"/> <ImageView android:id="@+id/iconusu" android:layout_marginTop="20dp" android:layout_width="150dp" android:layout_height="150dp" android:layout_gravity="center" android:src="@drawable/ic_usu"/> <TextView android:id="@+id/textView5" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:layout_marginTop="80dp" android:text="PROGRAM STUDI S1 ILMU KOMPUTER\nFAKULTAS ILMU KOMPUTER DAN TEKNOLOGI INFORMASI UNIVERSITAS SUMATERA UTARA\n2014"/> </LinearLayout>

12. Activity_add.xml

  <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/input_content" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="vertical" >

  <ImageView android:id="@+id/input_image" android:layout_width="match_parent" android:layout_height="150dp" android:src="@drawable/icon_user" /> <EditText android:id="@+id/input_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Nama" android:inputType="textPersonName" /> <EditText android:id="@+id/input_phone" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Handphone" android:inputType="number" /> <EditText android:id="@+id/input_email" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Email" android:inputType="textEmailAddress" /> <EditText android:id="@+id/input_alamat" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Address" android:inputType="textMultiLine" /> <EditText android:id="@+id/input_catatan" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Note" android:inputType="textMultiLine" /> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:id="@+id/btn_cancel" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:textColor="@color/white" android:background="#444069" android:text="Cancel" /> <Button android:id="@+id/btn_done" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:textColor="@color/white" android:background="#444069" android:text="Done" /> </LinearLayout> </LinearLayout>

13. Activity_edit.xml

  <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:id="@+id/input_content" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:orientation="vertical" > <ImageView android:id="@+id/edit_image" android:layout_width="match_parent" android:layout_height="150dp" android:src="@drawable/icon_user" /> <EditText android:id="@+id/edit_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Name" android:inputType="textPersonName" /> <EditText android:id="@+id/edit_phone" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Handphone" android:inputType="number" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Email" android:inputType="textEmailAddress" /> <EditText android:id="@+id/edit_alamat" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Address" android:inputType="textMultiLine" /> <EditText android:id="@+id/edit_catatan" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Note" android:inputType="textMultiLine" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <Button android:id="@+id/btn_cancel" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="#444069" android:textColor="@color/white" android:text="Cancel" /> <Button android:id="@+id/btn_done" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="#444069" android:textColor="@color/white" android:text="Done" /> </LinearLayout> </LinearLayout>

14. Activity_help.xml

  <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" >

  <TextView android:layout_width="match_parent" android:gravity="center" android:background="@color/redpa" android:textColor="@color/white" android:textSize="16dp" android:text="Petunjuk Penggunaan Contact Manager" /> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp" android:text="1.Gunakan actionbar tambah " /> <ImageView android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:src="@drawable/icon_add" android:background="@color/black" /> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp" android:text="untuk menambah contact baru" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginTop="8dp" android:background="#ddd" />

  <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp" android:text="2.Gunakan actionbar Search " /> <ImageView android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:src="@drawable/icon_search" android:background="@color/black" /> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp" android:text="untuk mencari contact" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginTop="8dp" android:background="#ddd" />

  <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp" android:text="3.Gunakan actionbar edit " /> <ImageView android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:src="@drawable/icon_edit" android:background="@color/black" /> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp" android:text="untuk mengedit contact" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginTop="8dp" android:background="#ddd" />

  <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp" android:text="4.Gunakan actionbar delete " /> <ImageView android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:src="@drawable/icon_delete" android:background="@color/black" /> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp" android:text="untuk menghapus contact" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginTop="8dp" android:background="#ddd" />

  <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp" android:text="5.Gunakan actionbar navigasi " /> <ImageView android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:background="@color/black" android:src="@drawable/ic_drawer" /> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp" android:text="untuk melihat menu navigasi" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginTop="8dp" android:background="#ddd" />

  <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp" android:text="6.Gunakan navigasi help " /> <ImageView android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:src="@drawable/ic_help" android:background="@color/white" /> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp" android:text="untuk melihat bantuan" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginTop="8dp" android:background="#ddd" />

  <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp" android:text="7.Gunakan navigasi about " /> <ImageView android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:src="@drawable/ic_about" android:background="@color/white" /> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp" android:text="untuk melihat tentang pembuat dan aplikasi" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginTop="8dp" android:background="#ddd" />

  <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp" android:text="8.Gunakan button call " /> <ImageView android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:src="@drawable/ic_call" android:background="@color/white" /> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp" android:text="untuk memanggil contact" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginTop="8dp" android:background="#ddd" />

  <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp" android:text="9.Gunakan button message " /> <ImageView android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:src="@drawable/ic_message" android:background="@color/white" /> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp" android:text="untuk mengirim pesan teks" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginTop="8dp" android:background="#ddd" />

  <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="10dp" android:text="10.Gunakan button email " /> <ImageView android:layout_width="wrap_content" android:layout_marginLeft="10dp" android:layout_height="wrap_content" android:src="@drawable/ic_email" android:background="@color/white" /> <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="10dp" android:text="untuk mengirim pesan email" /> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_marginTop="8dp" android:background="#ddd" />

  </LinearLayout> </ScrollView>

15. Activity_detail.xml

  <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <View android:layout_width="match_parent" android:layout_height="10dp" android:background="#ddd" /> <ImageView android:id="@+id/thumb_detail" android:layout_width="match_parent" android:layout_height="150dp" android:scaleType="fitCenter" android:src="@drawable/icon_user" /> <View android:layout_width="match_parent" android:layout_height="10dp" android:layout_marginTop="3dp" android:background="#ddd" />