• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
HIT3328 - Chapter0601 - Menus and Lists
 

HIT3328 - Chapter0601 - Menus and Lists

on

  • 270 views

 

Statistics

Views

Total Views
270
Views on SlideShare
270
Embed Views
0

Actions

Likes
0
Downloads
1
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    HIT3328 - Chapter0601 - Menus and Lists HIT3328 - Chapter0601 - Menus and Lists Presentation Transcript

    • HIT3328 / HIT8328 Software Development forMobile DevicesDr. Rajesh Vasa, 20111Twitter: @rvasaBlog: http://rvasa.blogspot.comLecture 06Menus and Lists
    • R. Vasa, 20112Lecture Overview•Working with Menus•Using Frame Layout•Adapters and Working with Simple Lists
    • R. Vasa, 20113Menus•Android offers a ‘Menu’ button, iOS does not•Menus’ can be customised per activityMenus have a label and an iconIcon is strongly recommended bythe Android UI guidelinesMenuIcons at different resolutionsshould be provided (ideally)
    • R. Vasa, 20114Creating a MenuName App (from Lecture5)Menus are defined as aresourceWe can use icons provided byAndroid SDK (recommended)We can use icons provided byAndroid SDK (recommended)
    • R. Vasa, 20115Menus are ResourcesConvention is to place itin ‘menu’ folder
    • R. Vasa, 20116Wiring up a Menu to ShowCall back method that we have to writeResource IdentifierXML Resource file is converted (inflated)into a Menu object that will be rendered(shown) on screenXML Resource file is converted (inflated)into a Menu object that will be rendered(shown) on screen
    • R. Vasa, 20117Handling Menu ClickCall back method that we have to write
    • R. Vasa, 20118Toasting a Message•There is often a need to show a messagefor a short period and then fade on mobiledevices•Android offers this via the Toast utility
    • R. Vasa, 20119Toasting a MessageOn ClickMessagedisplayed for asecond
    • R. Vasa, 20111Creating a ToastDuration can be customisedAndroid offers Toast.LENGTH_LONG,Toast.LENGTH_SHORT as built in defaultsDuration can be customisedAndroid offers Toast.LENGTH_LONG,Toast.LENGTH_SHORT as built in defaults
    • R. Vasa, 20111Lecture Roadmap - Where arewe?•Working with Menus•Using Frame Layout•Adapters and Working with Simple Lists
    • R. Vasa, 20111Frame Layout Offers Overlays•We often need a way to overlay multipleviews (or layouts) on top of each other•Often with variation in transparency•Frame Layout offers us this feature•Frame Layout is also used to help createTab Panes in Android
    • R. Vasa, 20111Simple Frame Layout (LightBulb)Button is placed on top of Image Viewn / Off Images are also placed on top of each othe
    • R. Vasa, 20111Frame Layout - Code2 Image Views and 1 Button in the same layout
    • R. Vasa, 20111Frame Layout - CodeWe control visibility explicitlyWe control visibility explicitly
    • R. Vasa, 20111Light Bulb LogicWe flip the visibility of the imagesMethod is triggered onClickMethod is triggered onClick
    • R. Vasa, 20111Lecture Roadmap - Where arewe?•Working with Menus•Using Frame Layout•Adapters and Working with SimpleLists
    • R. Vasa, 20111A Simple List App.Displays Latitude and Longitude of a location
    • R. Vasa, 20111Constituents of a List basedscreenListViewText Views
    • R. Vasa, 20112Lists get data via an AdapterListViewData SourceAdapter
    • R. Vasa, 20112Adapter Formats Data forDisplayListViewData SourceAdapterData is formatted fordisplay via customisedlayout attached to theAdapterData is formatted fordisplay via customisedlayout attached to theAdapter
    • R. Vasa, 20112List Views are very flexibleWe specify thelayout for each lineitem of a listLayout can be providedas a resource file (XML)
    • R. Vasa, 20112Adapter Feeds data to ListViewListViewData SourceAdapterData Source feeds datato the Adapter forformattingData Source feeds datato the Adapter forformatting
    • R. Vasa, 20112Adapter Offers Separation ofConcernsListViewData SourceAdapterData Source can be anarray, collection object,external database, or anexternal serverData Source can be anarray, collection object,external database, or anexternal server
    • R. Vasa, 20112Simple List App.ListViewData SourceAdapterDomain Model:HashMap (Cities, Location)(Cities names)(Simple ItemLayout)
    • R. Vasa, 20112Domain ModelIdeally, you read an external resource(Above data is hard-coded to illustrate concept)
    • R. Vasa, 20112Wiring up Data - Adapter -ListViewActivity extends ListActivityWe are using an Array Adapter(others are available / you canprovide your own)
    • R. Vasa, 20112Wiring up Data - Adapter -ListViewWe are using SDK provided layout style(we can also write our own as an Layout XML)
    • R. Vasa, 20112Wiring up Data - Adapter -ListViewWe are setting the data source to use
    • R. Vasa, 20113Wiring up Data - Adapter -ListViewTell the List View to display from adapter
    • R. Vasa, 20113Wiring up Data - Adapter -ListViewOnly one ListView can receivedata via the defaultsetListAdapter in an Activity
    • R. Vasa, 20113Activity LayoutListView that will receive dataprovided via setListAdapter
    • R. Vasa, 20113Activity LayoutListView that will receive dataprovided via setListAdapterSpecialbuilt-inidentifierSpecialbuilt-inidentifier
    • R. Vasa, 20113Handling List Click EventThis call back is provided by theparent (List Activity) class -- weoverride itThis call back is provided by theparent (List Activity) class -- weoverride it
    • R. Vasa, 20113But, what about complex lists?Key concepts are thesameWe will cover it later indepth(if you are curious, look at examplesonline)
    • R. Vasa, 20113Lecture Summary•Working with Menus•Using Frame Layout•Adapters and Working with Simple Lists