Building the Contacts App (Without Database)

Introducing some basic concepts

Created by Saksham Agarwal / Piyush Bhopalka

Understanding File Structure

manifest

java

res

All XML files are stored in res/layout
Most images used in the project will be stored in res/drawables

Understanding the layouts used in the app

Layouts for Contact App
For those who have attended the session should understand the image

Referencing from res to java

R.drawable.<image_id> - For images

R.layout.<layout_id> - For XML files

R.id.<view_id> - For Views (elements) inside a layout (XML file)

For reference,

The XML code for the contacts.xml and main_activity.xml are here.

Working on the Java Part

Let's first create a new Java file that defines each contact

We call it Human.java

Code for Human.java is here

Sample Images for the Project

Download the images from here. Put them in the res/drawables folder.

Let's complete MainActivity.java

  • First declare all the names as an object of class Human
  • Put them all in an ArrayList
  • Iteratively, populate the elements (objects) to the LinearLayout View
  • Add an intent to the RelativeLayout such that whenever it is clicked, ACTION_DIAL is invoked

Let's complete MainActivity.java

For reference, code is available here. But we suggest you to type it out yourself atleast.

Now run your app!

Voila! You have built your Contacts App

Demo of the Project

Your app should look something like this:

Contacts App Demo