Dynamic Contact List Creation in Android App

android topics n.w
1 / 14
Embed
Share

"Learn how to build an Android app with a scrollable contact list dynamically populated with 20 friend or family contacts. Explore step-by-step instructions on designing layouts, creating a data model, and implementing the controller in Java."

  • Android
  • Contact List
  • App Development
  • Dynamic Population
  • Java

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Android Topics Lab 5 Part II Build an app containing a Scrollable Contact List Dynamically populate the list with 20 friend (family) contacts

  2. App Structure Add the drawable Resources.

  3. Build the Layouts friend_layout.xml: Scrollable Contains an internal LinearLayout TIP: Research ScrollView contact_item.xml: LinearLayout

  4. friend_layout.xml: The main activity layout. components ScrollView LinearLayout Root View Internal LinearLayout that will hold a list of contacts.

  5. contact_item.xml: The visual display of a contact. components LinearLayout ImageView LinearLayout TextView TextView

  6. Data Model: Contact.java public String name; public String relationship; public int imageID;

  7. Controller: MainActivity.java Task 1: Instantiate a layout inflater to inflate individual friend contacts (contact_item) Task 2: Create a list of 20 Contact objects. Each Contact object should consist of a name, relationship, and a photo. Task 3: Reference the internal LinearLayout in the main activity. This is where the list of contacts will be displayed. Task 4: Dynamically create a View for each Contact object in the ArrayList and add it to the scrolling internal LinearLayout. Step a) Inflate a contract_item layout. Step b) Reference the ImageView and TextViews in the contact_item. Step c) Add content to the inflated contact_item. Step d) Add the contact_item to the internal LinearLayout.

  8. Controller: MainActivity.java Task 1: Instantiate a layout inflater to inflate individual friend contacts (contact_item) LayoutInflater layoutInflater = (LayoutInflater) getSystemService (Context.LAYOUT_INFLATER_SERVICE);

  9. Controller: MainActivity.java Task 2: Create a list of 20 Contact objects. Each Contact object should consist of a name, relationship, and a photo. ArrayList<Contact> contactList = new ArrayList<Contact>(); contactList.add(new Contact("Arthur Weasley", "father", R.drawable.male1)); . . .

  10. Controller: MainActivity.java Task 3: Reference the internal LinearLayout in the main activity. This is where the list of contacts will be displayed.

  11. Controller: MainActivity.java Task 4: Dynamically create a View for each Contact object in the ArrayList and add it to the scrolling internal LinearLayout. Step a) Inflate a contract_item layout.

  12. Controller: MainActivity.java Task 4: Step b) Reference the ImageView and TextViews in the contact_item. Example: Inflated contract_item layout TextView name_text = (TextView) myContactItem.findViewById(R.id.textView1); . . .

  13. Controller: MainActivity.java Task 4: Step c) Add content to the inflated contact_item. name_text.setText(contactList.get(i).name); . .

  14. Controller: MainActivity.java Task 4: Step d) Add the contact_item to the internal LinearLayout.

Related


More Related Content