• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Advanced Android Fragments, Tom Opgenorth
 

Advanced Android Fragments, Tom Opgenorth

on

  • 1,413 views

 

Statistics

Views

Total Views
1,413
Views on SlideShare
1,413
Embed Views
0

Actions

Likes
1
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

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

    Advanced Android Fragments, Tom Opgenorth Advanced Android Fragments, Tom Opgenorth Presentation Transcript

    • Tom OpgenorthDeveloper / WriterXamarintom.opgenorth@xamarin.comFragments - The Next Step(Advanced Fragments)@topgenorth
    • Topics to Look out For In this Session• Quick Review of Fragments• How Fragments can Help Their Host with State• Not ONE But TWO Fragments :DialogFragmentPreferenceFragment
    • Review
    • What Do We Need to Remember AboutFragments ?• Fragments Are Modular UIThink “mini-Activity”• Hosted in an ActivityStatically - in LayoutDynamically - at Runtime• They inflate views (usually)• They have a lifecycle
    • Retaining State
    • • Runtime / Changes kill ActivitiesState needs to be maintained• Custom objects to maintain stateSubclass Java.Lang.ObjectOverride OnRetainNonConfigurationInstanceCheck Activity.LastNonConfigurationInstanceBut these are DEPRECATED!Activity State Can Complex
    • - Leonardo da VinciSimplicity is the Ultimate Sophistication
    • this.RetainInstance = true;
    • How Does this Impact the FragmentLifecycle?StartOnInflate OnAttachOnCreateOnCreateViewOnActivityCreatedOnStartOnResumeOnPauseOnStopOnDestroyViewOnDestroyOnDetachRunningEnd
    • • Survives config changes!• Lightweight• Perfect forBackground Process (Threads)Memory intensive ResourcesSharing DataWhat Does This Mean - Exactly?
    • Demo 1
    • DialogFragment
    • Why Use DialogFragment?• Configuration changes are hard on dialogsDialog Should Remain - but the Activity is destroyed• Customizable• “Managed Dialogs” - Old School
    • How Do I Use DialogFragments?• Subclass DialogFragment• Override one of the following methods:OnCreateDialog• A “proper” dialog will pop upOnCreateView• Inflate a View - then embed it• Modal, but not blocking
    • Demo 2
    • PreferenceFragment
    • PreferenceFragment : Why Do I Care?• Preferred Way for Android 3.0 or Higher• Can Share Across Activities• Allows for HierarchiesPreferenceActivity Does Not
    • On A Tablet
    • On a Phone
    • Demo 3
    • What Were We Talking About Again?• Keep Fragments around with RetainInstance• DialogFragmentsDialog or EmbeddedModal but not Blocking!• PreferenceFragment
    • Q & A
    • THANK YOU