Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
75 views3 pages

Background: Exercise: Listview Example

This document discusses layouts, controls, and activities in Android mobile app development. It provides examples of implementing ListViews with single and multiple selection options. The objectives are to understand layouts, controls, activities, deploy a simple Android app, and implement ListViews with events. Background information and links are provided. An exercise walks through creating a project with a ListView that allows single selection of items. A second exercise adds multiple selection capability to the ListView.

Uploaded by

Vitor Santos
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views3 pages

Background: Exercise: Listview Example

This document discusses layouts, controls, and activities in Android mobile app development. It provides examples of implementing ListViews with single and multiple selection options. The objectives are to understand layouts, controls, activities, deploy a simple Android app, and implement ListViews with events. Background information and links are provided. An exercise walks through creating a project with a ListView that allows single selection of items. A second exercise adds multiple selection capability to the ListView.

Uploaded by

Vitor Santos
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

44139 – Mobile Computing@UA

17623 - Software Engineering in Mobile Computing@CMU


2010/2011
In-class #2 – Layouts and Controls

Objectives:
• Understanding layouts, controls and activities
• Deploy a simple Android application
• Understand and implement ListView with multiple events
Material:
• Class presentations
• Eclipse IDE with Android ADT

Background
- Please refer to the InClass presentations on
o “Dissecting Android Apps”
o “Android Components”
o “Android App Lifecycle”
o “Android Layout, Controls and Activities”

More details can be seen in http://elearning.ua.pt

Exercise: ListView Example


In Android, ListView is a control that is used to show a list of items in a vertically scrolling list. For example, in a
shopping list this control will have a set of items displayed for you in a vertical orientation. We can use Listview to
display the list of items.

In this example, we will have a list of selectable items.


Go to Eclipse and create a new project named “ListViewExample”.

Your res/main.xml file should look like this:

[jfernan, jcunha]@ua.pt 1/3


44139 – Mobile Computing@UA
In-class #2 – Layouts and Controls

And your src/.java file should look like this:

Notice the ListView declaration and its use as “lv1”.


The result should be something like this:

[jfernan, jcunha]@ua.pt 2/3


44139 – Mobile Computing@UA
In-class #2 – Layouts and Controls

Exercise: ListView with multiple choice


Let’s now make a more “fancy” ListView, where you can select multiple items of the list and have a nice icon to
denote their selection.
Go to Eclipse and create a new project named “ListMchoice”.
Your res/layout/main.xml file should look like this

Then, go to your src/.java file and add the following code:

Notice the differences from the previous example… the key is in the “setChoiceMode ()” method.
The result should look like this:

More details and other evolutions of this example to really “fancy” ListView apps can be found at:
http://www.androidpeople.com/tag/listview/

[jfernan, jcunha]@ua.pt 3/3

You might also like