• APP Activities Fragments


    http://developer.android.com/guide/components/fragments.html

    1. Fragments

        A Fragment represents a behavior or a portion of the user interface in an Activity.

                                         a modular section of an activity.

        A Fragment must always be embedded in an activity, and its lifecycle is directly affected by the host activity's lifecycle.

        Each back stack entry in the activity is a record of the fragment transaction that occured.

        Adding a fragment:

            (1) declare the fragment in the activity's layout file, as a <fragment> element.

            (2) add a fragment by adding it to an existing ViewGroup .

       A Fragment is not required to be a part of the activity layout, it can be used as an invisible worker without its own UI.

    2. Creating a fragment

        implementing at least the following lifecycle methods.

    onCreate()
    The system calls this when creating the fragment. Within your implementation, you should initialize essential components of the fragment that you want to retain when the fragment is paused or stopped, then resumed.
    onCreateView()
    The system calls this when it's time for the fragment to draw its user interface for the first time. To draw a UI for your fragment, you must return a View from this method that is the root of your fragment's layout. You can return null if the fragment does not provide a UI.
    onPause()
    The system calls this method as the first indication that the user is leaving the fragment (though it does not always mean the fragment is being destroyed). This is usually where you should commit any changes that should be persisted beyond the current user session (because the user might not come back).

    There are also a few subclasses that you might want to extend, instead of the base Fragment class:

    DialogFragment
    Displays a floating dialog. Using this class to create a dialog is a good alternative to using the dialog helper methods in the Activity class, because you can incorporate a fragment dialog into the back stack of fragments managed by the activity, allowing the user to return to a dismissed fragment.
    ListFragment
    Displays a list of items that are managed by an adapter (such as a SimpleCursorAdapter), similar to ListActivity. It provides several methods for managing a list view, such as the onListItemClick() callback to handle click events.
    PreferenceFragment
    Displays a hierarchy of Preference objects as a list, similar to PreferenceActivity. This is useful when creating a "settings" activity for your application.

    3. Adding a user interface

        To provide a layout for a fragment, you must implement the onCreateView() callback method, which the Android system calls when it's time for the fragment to draw its layout. Your implementation of this method must return a View that is the root of your fragment's layout. 

       

       

  • 相关阅读:
    .net开发COM组件之组件签名&注册
    msmq访问格式
    IIS宿主WCF服务*.svc Mime类型映射
    匿名方法的机种书写形式
    GMTUTC YYYY-MM-DDTHH:mm:ss.sssZ、YYYY-MM-DDTHH:mm:ss.sss+8:00意义及与北京时间转换
    允许浏览器下载exe.config文件
    WCF部署失败
    原码、补码、反码
    Java 符号引用 与 直接引用
    计算机理论基础知识
  • 原文地址:https://www.cnblogs.com/gavinwu/p/3104555.html
Copyright © 2020-2023  润新知