DataBufferAdapter | Android Developers

Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

Language
close

- - About
  - Wear
  - TV
  - Auto
- - Get Started
  - Devices
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
  - Google Services
  - Samples
- - Google Play
  - Essentials
  - Get Users
  - Engage & Retain
  - Monetize
  - Tools & Reference
  - Developer Stories

## Results

Loading...
Summary: Inherited Constants | Ctors | Methods | Inherited Methods | [Expand All]
public class

# DataBufferAdapter

extends BaseAdapter

java.lang.Object
↳ | android.widget.BaseAdapter
| ↳ | com.google.android.gms.drive.widget.DataBufferAdapter<T>

## Class Overview

A concrete BaseAdapter that is backed by concatenated DataBuffers. The assumptions and behaviors of this adapter parallel those of the ArrayAdapter:

- that the provided resource id in the simple constructors references a single TextView
- that more complex layouts use constructors taking a field id that references a TextView in the larger layout resource
- that the objects in the DataBuffer have an appropriate toString() method, which will be used to populate the TextView

If you need to modify how the objects display in the TextView, override their toString() method.

In addition, any DataBuffers added to this adapter are managed entirely by this adapter, including their life cycle. Be sure to call `clear()` anywhere you would otherwise close the data buffers used here, and if you want to manage their life cycles more granularly, you will need to override the behavior of clear(), as well as add your own management methods to ensure resources are properly managed within your application.

If you need something other than a single TextView for the data in this adapter, override `getView(int, View, ViewGroup)` to populate and return the type of view you want.

## Summary

[Expand] Inherited Constants
From interface android.widget.Adapter
int | IGNORE_ITEM_VIEW_TYPE |
int | NO_SELECTION |

Public Constructors
| DataBufferAdapter(Context context, int resource, int textViewResourceId, List<DataBuffer<T>> objects)
| DataBufferAdapter(Context context, int resource, int textViewResourceId)
| DataBufferAdapter(Context context, int resource, List<DataBuffer<T>> objects)
| DataBufferAdapter(Context context, int resource)
| DataBufferAdapter(Context context, int resource, int textViewResourceId, DataBuffer...<T> buffers)
| DataBufferAdapter(Context context, int resource, DataBuffer...<T> buffers)

Public Methods
void | append(DataBuffer<T> buffer) Appends the specified buffer to the end of the adapter.
void | clear() Closes and removes all buffers, and so all elements, from the adapter.
Context | getContext()
int | getCount()
View | getDropDownView(int position, View convertView, ViewGroup parent)
T | getItem(int position)
long | getItemId(int position)
View | getView(int position, View convertView, ViewGroup parent)
void | notifyDataSetChanged() This will also re-enable automatic notifications.
void | setDropDownViewResource(int resource) Sets the layout resource to create the drop down views.
void | setNotifyOnChange(boolean notifyOnChange) Control whether methods that change the list (`append(DataBuffer)`, `clear()`) automatically call `notifyDataSetChanged()`.

[Expand] Inherited Methods
From class android.widget.BaseAdapter
boolean | areAllItemsEnabled()
View | getDropDownView(int arg0, View arg1, ViewGroup arg2)
int | getItemViewType(int arg0)
int | getViewTypeCount()
boolean | hasStableIds()
boolean | isEmpty()
boolean | isEnabled(int arg0)
void | notifyDataSetChanged()
void | notifyDataSetInvalidated()
void | registerDataSetObserver(DataSetObserver arg0)
void | unregisterDataSetObserver(DataSetObserver arg0)
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
From interface android.widget.Adapter
abstract int | getCount()
abstract Object | getItem(int arg0)
abstract long | getItemId(int arg0)
abstract int | getItemViewType(int arg0)
abstract View | getView(int arg0, View arg1, ViewGroup arg2)
abstract int | getViewTypeCount()
abstract boolean | hasStableIds()
abstract boolean | isEmpty()
abstract void | registerDataSetObserver(DataSetObserver arg0)
abstract void | unregisterDataSetObserver(DataSetObserver arg0)
From interface android.widget.ListAdapter
abstract boolean | areAllItemsEnabled()
abstract boolean | isEnabled(int arg0)
From interface android.widget.SpinnerAdapter
abstract View | getDropDownView(int arg0, View arg1, ViewGroup arg2)

## Public Constructors

#### public DataBufferAdapter (Context context, int resource, int textViewResourceId, List<DataBuffer<T>> objects)

#### public DataBufferAdapter (Context context, int resource, int textViewResourceId)

#### public DataBufferAdapter (Context context, int resource, List<DataBuffer<T>> objects)

#### public DataBufferAdapter (Context context, int resource)

#### public DataBufferAdapter (Context context, int resource, int textViewResourceId, DataBuffer...<T> buffers)

#### public DataBufferAdapter (Context context, int resource, DataBuffer...<T> buffers)

## Public Methods

#### public void append (DataBuffer<T> buffer)

Appends the specified buffer to the end of the adapter.

#### public void clear ()

Closes and removes all buffers, and so all elements, from the adapter.

#### public Context getContext ()

#### public int getCount ()

#### public View getDropDownView (int position, View convertView, ViewGroup parent)

#### public T getItem (int position)

##### Throws

CursorIndexOutOfBoundsException |

#### public long getItemId (int position)

#### public View getView (int position, View convertView, ViewGroup parent)

#### public void notifyDataSetChanged ()

This will also re-enable automatic notifications. Pairing this with `setNotifyOnChange(boolean)` gives the ability to make a series of changes to the adapter without triggering multiple notifications at the same time. Use these two methods together to temporarily disable notifications for the purpose of batching operations on the adapter.

#### public void setDropDownViewResource (int resource)

Sets the layout resource to create the drop down views.

#### public void setNotifyOnChange (boolean notifyOnChange)

Control whether methods that change the list (`append(DataBuffer)`, `clear()`) automatically call `notifyDataSetChanged()`. If set to false, caller must manually call notifyDataSetChanged() to have the changes reflected in the attached view.

The default is true, and calling notifyDataSetChanged() resets the flag to true. Use this method if you want to make several changes to the adapter in a row, and don't need the view to update in between changes. This reduces the processing load for each operation significantly.

##### Parameters

notifyOnChange | if true, modifications to the list will automatically call `notifyDataSetChanged()`