Fragment Constructors
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| Fragment() |
Default constructor. |
| Fragment(IntPtr, JniHandleOwnership) |
Initializes a managed representation of an existing Java Native Interface object. |
Fragment()
Default constructor.
[Android.Runtime.Register(".ctor", "()V", "")]
public Fragment();
- Attributes
Remarks
Default constructor. Every fragment must have an empty constructor, so it can be instantiated when restoring its activity's state. It is strongly recommended that subclasses do not have other constructors with parameters, since these constructors will not be called when the fragment is re-instantiated; instead, arguments can be supplied by the caller with setArguments(Bundle) and later retrieved by the Fragment with getArguments(). Applications should generally not implement a constructor. Prefer onAttach(Context) instead. It is the first place application code can run where the fragment is ready to be used - the point where the fragment is actually associated with its context. Some applications may also want to implement onInflate(Activity, AttributeSet, Bundle) to retrieve attributes from a layout resource, although note this happens when the fragment is attached.
Android reference for android.app.Fragment.Fragment.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Applies to
Fragment(IntPtr, JniHandleOwnership)
Initializes a managed representation of an existing Java Native Interface object.
protected Fragment(IntPtr javaReference, Android.Runtime.JniHandleOwnership transfer);
new Android.App.Fragment : nativeint * Android.Runtime.JniHandleOwnership -> Android.App.Fragment
Parameters
- javaReference
-
IntPtr
nativeint
The Java Native Interface object reference.
- transfer
- JniHandleOwnership
The ownership transfer to apply to the Java Native Interface object reference.
Remarks
This constructor is called by the .NET for Android binding runtime when it creates a managed peer for an existing Java object.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.