A subclass of android.widget.ListView that is easier to use. It
provides methods like those in the List
interface (add
,
remove
, get
, and set
, among others) to manipulate
the contents of the list, as well as an accessor method getList()
that returns a List
that automatically refreshes the list view when
its structure is changed.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
ListView(Context context)
Creates a new
ListView . | ||||||||||
|
ListView(Context context, AttributeSet attrs)
Creates a new
ListView . | ||||||||||
|
ListView(Context context, AttributeSet attrs, int defStyle)
Creates a new
ListView . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void
|
add(int index, E item)
Inserts an item into the list view at the specified index.
| ||||||||||
boolean
|
add(E item)
Adds an item to the list view.
| ||||||||||
boolean
|
addAll(int index, Collection<? extends E> collection)
Inserts the items in the specified collection into the list view at the
specified index.
| ||||||||||
boolean
|
addAll(Collection<? extends E> collection)
Adds the items in the specified collection to the list view.
| ||||||||||
void
|
clear()
Removes all items from the list view.
| ||||||||||
E
|
get(int index)
Gets the element at the specified index from the list view.
| ||||||||||
List<E>
|
getList()
Gets the list of items that is managed by this list view.
| ||||||||||
E
|
getSelectedItem()
Gets the currently selected item in the list view.
| ||||||||||
void
|
refresh()
Refreshes the list view to update its contents from the list it manages.
| ||||||||||
E
|
remove(int index)
Removes the item at the specified index from the list view.
| ||||||||||
boolean
|
remove(E item)
Removes the specified item from the list view.
| ||||||||||
E
|
set(int index, E item)
Replaces the element at the specified index from the list view with
another item.
|
Methods inherited 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)
|
Creates a new ListView
.
Creates a new ListView
.
Creates a new ListView
.
Inserts an item into the list view at the specified index.
Adds an item to the list view.
true if the item could be added, or false if it could not
Inserts the items in the specified collection into the list view at the specified index.
true if the items could be added, or false if they could not
Adds the items in the specified collection to the list view.
rue if the items could be added, or false if they could not
Removes all items from the list view.
Gets the element at the specified index from the list view.
the item at the specified index
Gets the list of items that is managed by this list view. Changes made
to the structure of the list returned by this method (that is, adding,
removing, or replacing items) will be immediately reflected in the list
view. You only need to explicitly refresh()
the list if you
make a change to an element inside the list without directly modifying
the list itself.
the List
of items managed by this list view
Gets the currently selected item in the list view.
the currently selected item in the list view, or null if there is no item selected
Refreshes the list view to update its contents from the list it manages.
This method does not need to be called after methods like add
or remove
-- it only needs to be called if you change a property
of one of the elements in the list (for example, by calling a setter)
without modifying the structure of the list itself.
Removes the item at the specified index from the list view.
the item that was removed
Removes the specified item from the list view.
true if the item was found and removed, or false if it was not
Replaces the element at the specified index from the list view with another item.
the item previously at the specified index