Your SlideShare is downloading. ×
0
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
HIT3328 - Chapter0601 - Menus and Lists
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

HIT3328 - Chapter0601 - Menus and Lists

135

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
135
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

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

×