public class BindingListViewAdapter<T> extends BaseAdapter implements BindingCollectionAdapter<T>
BaseAdapter that binds items to layouts using the given ItemBinding 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 |
BindingListViewAdapter.ItemIds<T> |
static interface |
BindingListViewAdapter.ItemIsEnabled<T> |
| Constructor and Description |
|---|
BindingListViewAdapter(int itemTypeCount)
Constructs a new instance with the given item count.
|
| Modifier and Type | Method and Description |
|---|---|
T |
getAdapterItem(int position)
Returns the item in the adapter given position.
|
int |
getCount() |
View |
getDropDownView(int position,
View convertView,
ViewGroup parent) |
T |
getItem(int position) |
ItemBinding<T> |
getItemBinding()
Returns the
ItemBinding that the adapter that was set. |
long |
getItemId(int position) |
int |
getItemViewType(int position) |
View |
getView(int position,
View convertView,
ViewGroup parent) |
int |
getViewTypeCount() |
boolean |
hasStableIds() |
boolean |
isEnabled(int position) |
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 |
setDropDownItemLayout(int layoutRes)
Set a different layout to show for
getDropDownView(int, View, ViewGroup). |
void |
setItemBinding(ItemBinding<T> itemBinding)
Sets the item biding for the adapter.
|
void |
setItemIds(BindingListViewAdapter.ItemIds<? super T> itemIds)
Set the item id's for the items.
|
void |
setItemIsEnabled(BindingListViewAdapter.ItemIsEnabled<? super T> itemIsEnabled)
Sets
isEnabled(int) for the items. |
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. |
public BindingListViewAdapter(int itemTypeCount)
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 setDropDownItemLayout(int layoutRes)
getDropDownView(int, View, ViewGroup). If this is
null, it will default to getView(int, View, ViewGroup).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 setItemIds(BindingListViewAdapter.ItemIds<? super T> itemIds)
hasStableIds() return
true.public void setItemIsEnabled(BindingListViewAdapter.ItemIsEnabled<? super T> itemIsEnabled)
isEnabled(int) for the items.public int getCount()
public T getItem(int position)
public long getItemId(int position)
public boolean isEnabled(int position)
public final View getView(int position,
View convertView,
ViewGroup parent)
public final View getDropDownView(int position,
View convertView,
ViewGroup parent)
public int getItemViewType(int position)
public boolean hasStableIds()
public int getViewTypeCount()