Skip to content

Most visited

Recently visited

navigation

ObservableArrayList

public class ObservableArrayList
extends ArrayList<T> implements ObservableList<T>

java.lang.Object
   ↳ java.util.AbstractCollection<T>
     ↳ java.util.AbstractList<T>
       ↳ java.util.ArrayList<T>
         ↳ android.databinding.ObservableArrayList<T>


An ObservableList implementation using ArrayList as an implementation.

Summary

Inherited fields

From class java.util.AbstractList

Public constructors

ObservableArrayList()

Public methods

boolean add(T object)

Appends the specified element to the end of this list.

void add(int index, T object)

Inserts the specified element at the specified position in this list.

boolean addAll(Collection<? extends T> collection)

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's Iterator.

boolean addAll(int index, Collection<? extends T> collection)

Inserts all of the elements in the specified collection into this list, starting at the specified position.

void addOnListChangedCallback(OnListChangedCallback listener)
void clear()

Removes all of the elements from this list.

T remove(int index)

Removes the element at the specified position in this list.

boolean remove(Object object)

Removes the first occurrence of the specified element from this list, if it is present.

void removeOnListChangedCallback(OnListChangedCallback listener)
T set(int index, T object)

Replaces the element at the specified position in this list with the specified element.

Protected methods

void removeRange(int fromIndex, int toIndex)

Removes from this list all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive.

Inherited methods

From class java.util.ArrayList
From class java.util.AbstractList
From class java.util.AbstractCollection
From class java.lang.Object
From interface java.util.List
From interface java.util.Collection
From interface android.databinding.ObservableList
From interface java.lang.Iterable
From interface java.util.List

Public constructors

ObservableArrayList

ObservableArrayList ()

Public methods

add

boolean add (T object)

Appends the specified element to the end of this list.

Parameters
object T: element to be appended to this list

Returns
boolean true (as specified by add(E))

add

void add (int index, 
                T object)

Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Parameters
index int: index at which the specified element is to be inserted

object T: element to be inserted

addAll

boolean addAll (Collection<? extends T> collection)

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's Iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this list, and this list is nonempty.)

Parameters
collection Collection: collection containing elements to be added to this list

Returns
boolean true if this list changed as a result of the call

addAll

boolean addAll (int index, 
                Collection<? extends T> collection)

Inserts all of the elements in the specified collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in the list in the order that they are returned by the specified collection's iterator.

Parameters
index int: index at which to insert the first element from the specified collection

collection Collection: collection containing elements to be added to this list

Returns
boolean true if this list changed as a result of the call

addOnListChangedCallback

void addOnListChangedCallback (OnListChangedCallback listener)

Parameters
listener OnListChangedCallback

clear

void clear ()

Removes all of the elements from this list. The list will be empty after this call returns.

remove

T remove (int index)

Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices).

Parameters
index int: the index of the element to be removed

Returns
T the element that was removed from the list

remove

boolean remove (Object object)

Removes the first occurrence of the specified element from this list, if it is present. If the list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an element exists). Returns true if this list contained the specified element (or equivalently, if this list changed as a result of the call).

Parameters
object Object: element to be removed from this list, if present

Returns
boolean true if this list contained the specified element

removeOnListChangedCallback

void removeOnListChangedCallback (OnListChangedCallback listener)

Parameters
listener OnListChangedCallback

set

T set (int index, 
                T object)

Replaces the element at the specified position in this list with the specified element.

Parameters
index int: index of the element to replace

object T: element to be stored at the specified position

Returns
T the element previously at the specified position

Protected methods

removeRange

void removeRange (int fromIndex, 
                int toIndex)

Removes from this list all of the elements whose index is between fromIndex, inclusive, and toIndex, exclusive. Shifts any succeeding elements to the left (reduces their index). This call shortens the list by (toIndex - fromIndex) elements. (If toIndex==fromIndex, this operation has no effect.)

Parameters
fromIndex int: index of first element to be removed

toIndex int: index after last element to be removed

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)