public class BindingViewPagerAdapter<T> extends PagerAdapter implements BindingCollectionAdapter<T>
PagerAdapter that binds items to layouts using the given ItemBinding or OnItemBind. If you give it an ObservableList it will also updated itself based on
changes to that list.| Modifier and Type | Class and Description |
|---|---|
static interface |
BindingViewPagerAdapter.PageTitles<T> |
| Constructor and Description |
|---|
BindingViewPagerAdapter() |
| Modifier and Type | Method and Description |
|---|---|
void |
destroyItem(ViewGroup container,
int position,
java.lang.Object object) |
T |
getAdapterItem(int position)
Returns the item in the adapter given position.
|
int |
getCount() |
ItemBinding<T> |
getItemBinding()
Returns the
ItemBinding that the adapter that was set. |
int |
getItemPosition(java.lang.Object object) |
java.lang.CharSequence |
getPageTitle(int position) |
java.lang.Object |
instantiateItem(ViewGroup container,
int position) |
boolean |
isViewFromObject(View view,
java.lang.Object object) |
void |
onBindBinding(ViewDataBinding binding,
int variableId,
int layoutRes,
int position,
T item)
Called to bind the given item to the binding.
|
ViewDataBinding |
onCreateBinding(LayoutInflater inflater,
int layoutRes,
ViewGroup viewGroup)
Called to create a binding.
|
void |
setItemBinding(ItemBinding<T> itemBinding)
Sets the item biding for the adapter.
|
void |
setItems(java.util.List<T> items)
Sets the adapter's items.
|
void |
setLifecycleOwner(LifecycleOwner lifecycleOwner)
Sets the lifecycle owner of this adapter to work with
androidx.lifecycle.LiveData. |
void |
setPageTitles(BindingViewPagerAdapter.PageTitles<T> pageTitles)
Sets the page titles for the adapter.
|
public void setItemBinding(ItemBinding<T> itemBinding)
BindingCollectionAdaptersetItemBinding in interface BindingCollectionAdapter<T>public void setLifecycleOwner(LifecycleOwner lifecycleOwner)
androidx.lifecycle.LiveData.
This is normally not necessary, but due to an androidx limitation, you need to set this if
the containing view is not using databinding.public ItemBinding<T> getItemBinding()
BindingCollectionAdapterItemBinding that the adapter that was set.getItemBinding in interface BindingCollectionAdapter<T>public void setItems(java.util.List<T> items)
BindingCollectionAdapterItemBinding. If
you pass in an ObservableList the adapter will also update itself based on that
list's changes. ObservableList, you must call notifyDataSetChanged() or one of
the related methods.setItems in interface BindingCollectionAdapter<T>public T getAdapterItem(int position)
BindingCollectionAdaptergetAdapterItem in interface BindingCollectionAdapter<T>public ViewDataBinding onCreateBinding(LayoutInflater inflater,
int layoutRes,
ViewGroup viewGroup)
BindingCollectionAdapterlayoutId and viewGroup. A subclass may override this and cast the result to a
specific layout binding to get at the generated view fields.onCreateBinding in interface BindingCollectionAdapter<T>public void onBindBinding(ViewDataBinding binding,
int variableId,
int layoutRes,
int position,
T item)
BindingCollectionAdapteronBindBinding in interface BindingCollectionAdapter<T>public void setPageTitles(BindingViewPagerAdapter.PageTitles<T> pageTitles)
public int getCount()
public java.lang.CharSequence getPageTitle(int position)
public java.lang.Object instantiateItem(ViewGroup container,
int position)
public void destroyItem(ViewGroup container,
int position,
java.lang.Object object)
public boolean isViewFromObject(View view,
java.lang.Object object)
public int getItemPosition(java.lang.Object object)