Android class reference --- Fragment (5)

Source: Internet
Author: User

Public void onCreateContextMenu (ContextMenu menu, View v, ContextMenu. ContextMenuInfo menuInfo)

This method is called when the context menu of the View object is displayed. Unlike onCreateOptionMenu (Menu, MenuInflater), this method is called every time the context Menu is displayed, and should be filled with the corresponding View object.

Use the onContextIntemSelected (android. view. MenuItem) method to obtain the selected menu item.

The default implementation of this method is to call the Activity. onCreateContextMenu method. However, if you do not want this default behavior, you can also choose not to call this implementation.

After this method is returned, it is insecure to hold the context menu. This method is called when the View object corresponding to the context menu is created.

Parameters

Menu this parameter specifies the context menu to be created.

V this parameter specifies the View object corresponding to the context menu to be created.

MenuInfo this parameter specifies the additional information of the context menu to be displayed. This information varies according to the type of the v parameter.

Public void onCreateOptionsMenu (Menu menu, MenuInflater inflater)

This method initializes the content of the standard option menu of the Activity. Place the menu item in the menu parameter. To call this method, you must first call the setHasOptionsMenu (boolean) method. For more information, see Activity. onCreateOptionsMenu.

Parameters

Menu this parameter specifies the option menu to place the menu item.

Public View onCreateView (LayoutInflater, inflater, ViewGroup container, Bundle savedInstanceState)

Call this method to initialize the Fragment user interface. This method is optional. For non-graphical Fragment objects, this method returns null (this is the default implementation ). This method is called between the onCreate (Bundle) and onActivityCreated (Bundle) methods.

If a View object is returned from this method, the onDestroyView () method is called when the View object is released.

Parameters

Inflager the LayoutInflater object can be used to fill any View object in the Fragment object.

Container if this parameter is not null, it specifies that the Fragment object UI should be bound to the Container to which this parameter points. It is the parent Container of the Fragment object. Fragment object should not add this View object to its layout, but can be used to generate the LayoutParams object of the View object.

SavedInstanceState if this parameter is not null, the Fragment object is rebuilt using the state value maintained in this parameter.

Return Value

This method returns the View object of the corresponding Fragment UI, or null.

Public void onDestroy ()

This method is called when Fragment is no longer used. It is called after the onStop () method and before the onDetach () method.

Public void onDestroyOptionsMenu ()

This method is called when the option menu item of this Fragment is no longer included in the overall option menu. When this call is received, the Menu needs to be rebuilt, but the Fragment project is not included in the newly created Menu (its onCreateOptionsMenu (Menu, MenuInflater) method will not be called ).

Public void onDestroyView ()

The system calls this method when the View object created by using the onCreateView (LayoutInflater, ViewGroup, Bundle) method is unbound from the Fragment object. The next time you need to display this Fragment object, you need to create a View object. This method is called after the onStop () method and before the onDestroy () method. Calling this method is irrelevant to whether the onCreateView (LayoutInflater, ViewGroup, Bundle) method returns a non-empty View object. In the call of this method, you must first save the status of the View object before deleting it from the parent object.

Public void onDetach ()

When this Fragment object is not bound to its Activity, the system will call this method. It is called after the onDestroy () method.

Public void onHiddenChanged (boolean hidden)

When this Fragment object changes the hidden state (returned by the isHidden () method), the system will call this method. Fragment is not hidden at first. This method is called as long as the Fragment object changes its display status.

Parameters

Hidden if the Fragment object is hidden, the parameter is true; otherwise, the parameter is false.

Public void onInflate (AttributeSet attrs, Bundle savedInstanceState)

This method has been deprecated after API Level 12. Use the onInflate (Activity, AttributeSet, Bundle) method instead.

 

 

From FireOfStar's column

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.