码迷,mamicode.com
首页 > 其他好文 > 详细

Fragment

时间:2016-02-29 12:08:05      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:

Building a Dynamic UI with Fragments

To create a dynamic and multi-pane user interface on Android, you need to encapsulate UI components and activity behaviors into modules that you can swap into and out of your activities. You can create these modules with the Fragment class, which behaves somewhat like a nested activity that can define its own layout and manage its own lifecycle.

  • When a fragment specifies its own layout, it can be configured in different combinations with other fragments inside an activity to modify your layout configuration for different screen sizes (a small screen might show one fragment at a time, but a large screen can show two or more).
  • This class shows you how to create a dynamic user experience with fragments and optimize your app‘s user experience for devices with different screen sizes, all while continuing to support devices running versions as old as Android 1.6.

Lessons

Creating a Fragment

  Learn how to build a fragment and implement basic behaviors within its callback methods.

Building a Flexible UI

  Learn how to build your app with layouts that provide different fragment configurations for different screens.

Communicating with Other Fragments

  Learn how to set up communication paths from a fragment to the activity and other fragments.

 

Get started

 

 

Dependencies and prerequisites

You should also read

 

用Fragment创建一个灵活的UI

在Android上为了实现一个灵活的、多窗口的交互界面,你可以创建一些Fragment将UI界面和在Activity中的相关操作封装成相应模块,以便在你的activity中可以自由切换。在某些地方,它就像一个嵌套的Activity,比如可以自定义布局和拥有自己的生命周期。

  • 一个fragment定义了自己的布局后,它可以在activity中与其他的fragment生成不同的组合,从而为不同的屏幕尺寸生成不同的布局(一个小的屏幕一次也许只能一个fragment,大的屏幕则可以显示更多)。
  • 本章将展示如何用fragment来创建动态界面,并在不同屏幕尺寸的设备上优化APP的用户体验。即使是运行着android1.6这样老版本的设备,也都能够继续得到支持。

课程目录

  • 创建一个fragment

    学习如何创建一个fragment,以及实现其生命周期内的基本功能。

  • 构建有灵活的UI

    学习在APP内,对不同的屏幕尺寸用fragment构建不同的布局。

开始学习

 

你需要必看的内容

 

你可以选看的内容

完整的Demo示例:FragmentBasics.zip

 

部分翻译来自

使用Fragment建立动态UI

Fragment

标签:

原文地址:http://www.cnblogs.com/404map/p/5224718.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!