HIT3328 / HIT8328 Software Development forMobile DevicesDr. Rajesh Vasa, 20111Twitter: @rvasaBlog: http://rvasa.blogspot.c...
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 a...
R. Vasa, 20114Creating a MenuName App (from Lecture5)Menus are defined as aresourceWe can use icons provided byAndroid SDK...
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 conver...
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•...
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 de...
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•...
R. Vasa, 20111Simple Frame Layout (LightBulb)Button is placed on top of Image Viewn / Off Images are also placed on top of...
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 a...
R. Vasa, 20112List Views are very flexibleWe specify thelayout for each lineitem of a listLayout can be providedas a resou...
R. Vasa, 20112Adapter Feeds data to ListViewListViewData SourceAdapterData Source feeds datato the Adapter forformattingDa...
R. Vasa, 20112Adapter Offers Separation ofConcernsListViewData SourceAdapterData Source can be anarray, collection object,...
R. Vasa, 20112Simple List App.ListViewData SourceAdapterDomain Model:HashMap (Cities, Location)(Cities names)(Simple ItemL...
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 avai...
R. Vasa, 20112Wiring up Data - Adapter -ListViewWe are using SDK provided layout style(we can also write our own as an Lay...
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 Acti...
R. Vasa, 20113Activity LayoutListView that will receive dataprovided via setListAdapter
R. Vasa, 20113Activity LayoutListView that will receive dataprovided via setListAdapterSpecialbuilt-inidentifierSpecialbui...
R. Vasa, 20113Handling List Click EventThis call back is provided by theparent (List Activity) class -- weoverride itThis ...
R. Vasa, 20113But, what about complex lists?Key concepts are thesameWe will cover it later indepth(if you are curious, loo...
R. Vasa, 20113Lecture Summary•Working with Menus•Using Frame Layout•Adapters and Working with Simple Lists
Upcoming SlideShare
Loading in …5
×

HIT3328 - Chapter0601 - Menus and Lists

308 views

Published on

Published in: Technology, Art & Photos
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
308
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

HIT3328 - Chapter0601 - Menus and Lists

  1. 1. HIT3328 / HIT8328 Software Development forMobile DevicesDr. Rajesh Vasa, 20111Twitter: @rvasaBlog: http://rvasa.blogspot.comLecture 06Menus and Lists
  2. 2. R. Vasa, 20112Lecture Overview•Working with Menus•Using Frame Layout•Adapters and Working with Simple Lists
  3. 3. 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)
  4. 4. 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)
  5. 5. R. Vasa, 20115Menus are ResourcesConvention is to place itin ‘menu’ folder
  6. 6. 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
  7. 7. R. Vasa, 20117Handling Menu ClickCall back method that we have to write
  8. 8. 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
  9. 9. R. Vasa, 20119Toasting a MessageOn ClickMessagedisplayed for asecond
  10. 10. 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
  11. 11. R. Vasa, 20111Lecture Roadmap - Where arewe?•Working with Menus•Using Frame Layout•Adapters and Working with Simple Lists
  12. 12. 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
  13. 13. R. Vasa, 20111Simple Frame Layout (LightBulb)Button is placed on top of Image Viewn / Off Images are also placed on top of each othe
  14. 14. R. Vasa, 20111Frame Layout - Code2 Image Views and 1 Button in the same layout
  15. 15. R. Vasa, 20111Frame Layout - CodeWe control visibility explicitlyWe control visibility explicitly
  16. 16. R. Vasa, 20111Light Bulb LogicWe flip the visibility of the imagesMethod is triggered onClickMethod is triggered onClick
  17. 17. R. Vasa, 20111Lecture Roadmap - Where arewe?•Working with Menus•Using Frame Layout•Adapters and Working with SimpleLists
  18. 18. R. Vasa, 20111A Simple List App.Displays Latitude and Longitude of a location
  19. 19. R. Vasa, 20111Constituents of a List basedscreenListViewText Views
  20. 20. R. Vasa, 20112Lists get data via an AdapterListViewData SourceAdapter
  21. 21. R. Vasa, 20112Adapter Formats Data forDisplayListViewData SourceAdapterData is formatted fordisplay via customisedlayout attached to theAdapterData is formatted fordisplay via customisedlayout attached to theAdapter
  22. 22. R. Vasa, 20112List Views are very flexibleWe specify thelayout for each lineitem of a listLayout can be providedas a resource file (XML)
  23. 23. R. Vasa, 20112Adapter Feeds data to ListViewListViewData SourceAdapterData Source feeds datato the Adapter forformattingData Source feeds datato the Adapter forformatting
  24. 24. 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
  25. 25. R. Vasa, 20112Simple List App.ListViewData SourceAdapterDomain Model:HashMap (Cities, Location)(Cities names)(Simple ItemLayout)
  26. 26. R. Vasa, 20112Domain ModelIdeally, you read an external resource(Above data is hard-coded to illustrate concept)
  27. 27. R. Vasa, 20112Wiring up Data - Adapter -ListViewActivity extends ListActivityWe are using an Array Adapter(others are available / you canprovide your own)
  28. 28. R. Vasa, 20112Wiring up Data - Adapter -ListViewWe are using SDK provided layout style(we can also write our own as an Layout XML)
  29. 29. R. Vasa, 20112Wiring up Data - Adapter -ListViewWe are setting the data source to use
  30. 30. R. Vasa, 20113Wiring up Data - Adapter -ListViewTell the List View to display from adapter
  31. 31. R. Vasa, 20113Wiring up Data - Adapter -ListViewOnly one ListView can receivedata via the defaultsetListAdapter in an Activity
  32. 32. R. Vasa, 20113Activity LayoutListView that will receive dataprovided via setListAdapter
  33. 33. R. Vasa, 20113Activity LayoutListView that will receive dataprovided via setListAdapterSpecialbuilt-inidentifierSpecialbuilt-inidentifier
  34. 34. 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
  35. 35. R. Vasa, 20113But, what about complex lists?Key concepts are thesameWe will cover it later indepth(if you are curious, look at examplesonline)
  36. 36. R. Vasa, 20113Lecture Summary•Working with Menus•Using Frame Layout•Adapters and Working with Simple Lists

×