java.lang.Object | |
↳ | android.databinding.DataBindingUtil |
Utility class to create ViewDataBinding
from layouts.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the binding for the given layout root or creates a binding if one
does not exist.
| |||||||||||
Returns the binding for the given layout root or creates a binding if one
does not exist.
| |||||||||||
Converts the given BR id to its string representation which might be useful for logging
purposes.
| |||||||||||
Retrieves the binding responsible for the given View.
| |||||||||||
Retrieves the binding responsible for the given View layout root.
| |||||||||||
Returns the default
DataBindingComponent used in data binding.
| |||||||||||
Inflates a binding layout and returns the newly-created binding for that layout.
| |||||||||||
Inflates a binding layout and returns the newly-created binding for that layout.
| |||||||||||
Set the Activity's content view to the given layout and return the associated binding.
| |||||||||||
Set the Activity's content view to the given layout and return the associated binding.
| |||||||||||
Set the default
DataBindingComponent to use for data binding.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Returns the binding for the given layout root or creates a binding if one
does not exist. This uses the DataBindingComponent set in
setDefaultComponent(DataBindingComponent)
.
Prefer using the generated Binding's bind
method to ensure type-safe inflation
when it is known that root
has not yet been bound.
root | The root View of the inflated binding layout. |
---|
IllegalArgumentException | when root is not from an inflated binding layout. |
---|
Returns the binding for the given layout root or creates a binding if one does not exist.
Prefer using the generated Binding's bind
method to ensure type-safe inflation
when it is known that root
has not yet been bound.
root | The root View of the inflated binding layout. |
---|---|
bindingComponent | The DataBindingComponent to use in data binding. |
IllegalArgumentException | when root is not from an inflated binding layout. |
---|
Converts the given BR id to its string representation which might be useful for logging purposes.
id | The integer id, which should be a field from BR class. |
---|
Retrieves the binding responsible for the given View. If view
is not a
binding layout root, its parents will be searched for the binding. If there is no binding,
null
will be returned.
This differs from getBinding(View)
in that findBinding takes any view in the
layout and searches for the binding associated with the root. getBinding
takes only the root view.
view | A View in the bound layout. |
---|
null
if
view is not part of a bound layout.
Retrieves the binding responsible for the given View layout root. If there is no binding,
null
will be returned. This uses the DataBindingComponent set in
setDefaultComponent(DataBindingComponent)
.
view | The root View in the layout with binding. |
---|
null
if
either the view is not a root View for a layout or view hasn't been bound.
Returns the default DataBindingComponent
used in data binding. This can be
null
if no default was set in
setDefaultComponent(DataBindingComponent)
.
DataBindingComponent
used in data binding. This can be
null
if no default was set in
setDefaultComponent(DataBindingComponent)
.
Inflates a binding layout and returns the newly-created binding for that layout.
This uses the DataBindingComponent set in
setDefaultComponent(DataBindingComponent)
.
Use this version only if layoutId
is unknown in advance. Otherwise, use
the generated Binding's inflate method to ensure type-safe inflation.
inflater | The LayoutInflater used to inflate the binding layout. |
---|---|
layoutId | The layout resource ID of the layout to inflate. |
parent | Optional view to be the parent of the generated hierarchy (if attachToParent is true), or else simply an object that provides a set of LayoutParams values for root of the returned hierarchy (if attachToParent is false.) |
attachToParent | Whether the inflated hierarchy should be attached to the parent parameter. If false, parent is only used to create the correct subclass of LayoutParams for the root view in the XML. |
null
if
the layoutId wasn't for a binding layout.InflateException | When a merge layout was used and attachToParent was false. |
---|
Inflates a binding layout and returns the newly-created binding for that layout.
Use this version only if layoutId
is unknown in advance. Otherwise, use
the generated Binding's inflate method to ensure type-safe inflation.
inflater | The LayoutInflater used to inflate the binding layout. |
---|---|
layoutId | The layout resource ID of the layout to inflate. |
parent | Optional view to be the parent of the generated hierarchy (if attachToParent is true), or else simply an object that provides a set of LayoutParams values for root of the returned hierarchy (if attachToParent is false.) |
attachToParent | Whether the inflated hierarchy should be attached to the parent parameter. If false, parent is only used to create the correct subclass of LayoutParams for the root view in the XML. |
bindingComponent | The DataBindingComponent to use in the binding. |
null
if
the layoutId wasn't for a binding layout.InflateException | When a merge layout was used and attachToParent was false. |
---|
Set the Activity's content view to the given layout and return the associated binding. The given layout resource must not be a merge layout.
activity | The Activity whose content View should change. |
---|---|
layoutId | The resource ID of the layout to be inflated, bound, and set as the Activity's content. |
Set the Activity's content view to the given layout and return the associated binding. The given layout resource must not be a merge layout.
activity | The Activity whose content View should change. |
---|---|
layoutId | The resource ID of the layout to be inflated, bound, and set as the Activity's content. |
bindingComponent | The DataBindingComponent to use in data binding. |
Set the default DataBindingComponent
to use for data binding.
bindingComponent
may be passed as the first parameter of binding adapters.
When instance method BindingAdapters are used, the class instance for the binding adapter is retrieved from the DataBindingComponent.