Android Programming Press on the image to return to the main documentation page.

Collections (Core)

List of types:

List
Map

List

List is similar to a dynamic array of objects. You can add, insert or remove items from the list.
Note that arrays are converted to lists automatically when needed.

Events:

None

Members:


  Add (Item As Object)

  AddAll (List As List)

  AddAllAt (Index As Int, List As List)

  Clear

  Get (Index As Int) As Object

  IndexOf (Item As Object) As Int

  Initialize

  Initialize2 (Array As List)

  InsertAt (Index As Int, Item As Object)

  IsInitialized As Boolean

  IsReadOnly As Boolean

  RemoveAt (Index As Int)

  Set (Index As Int, Item As Object)

  Size As Int [read only]

  Sort (Ascending As Boolean)

  SortCaseInsensitive (Ascending As Boolean)

  SortType (FieldName As String, Ascending As Boolean)

  SortTypeCaseInsensitive (FieldName As String, Ascending As Boolean)

  Tag As Object

Members description:

Add (Item As Object)
Adds an item to the end of the list.
AddAll (List As List)
Adds all the items from one list to the end of this list.
AddAllAt (Index As Int, List As List)
Adds all items from one list to this list, starting at the specified index.
Clear
Removes all items from the list.
Get (Index As Int) As Object
Returns the item in the specified index.
IndexOf (Item As Object) As Int
Returns the index of the specified item. Returns -1 if the item was not found.
Initialize
Initializes an empty list.
Initialize2 (Array As List)
Initializes a list that wraps the given array.
InsertAt (Index As Int, Item As Object)
Inserts an item in the specified index.
IsInitialized As Boolean
Tests whether this object was initialized.
IsReadOnly As Boolean
Tests whether the list is readonly. A list that is returned from a library call might be read-only.
RemoveAt (Index As Int)
Removes the item in the specified index.
Set (Index As Int, Item As Object)
Sets the item in the specified index.
Size As Int [read only]
Sort (Ascending As Boolean)
Sorts the list. If the first item in the in the list is a number then the list will be numerically sorted.
Otherwise the list will be lexicographically sorted.
SortCaseInsensitive (Ascending As Boolean)
Similar to Sort. Ignores the strings case.
SortType (FieldName As String, Ascending As Boolean)
Sorts a list with items of user defined type. The list is sorted based on the specified field.
FieldName - The case-sensitive field name that will be used for sorting. Field must contain numbers of strings.
Ascending - Whether to sort ascending or descending.
SortTypeCaseInsensitive (FieldName As String, Ascending As Boolean)
Similar to SortType. Ignores the strings case when sorting.
Tag As Object
Gets or sets the Tag object. This is a placeholder for any object you like to tie to this object.

Map

A collection that holds pairs of keys and values. The keys are unique. Fetching items is done based on the key.
Unlike B4J / B4A Maps, B4i Map does not retain the original order of items. You can iterate over the keys or values with the Keys or Values properties.

Events:

None

Members:


  Clear

  ContainsKey (Key As Object) As Boolean

  Get (Key As Object) As Object

  GetDefault (Key As Object, Default As Object) As Object

  Initialize

  IsInitialized As Boolean [read only]

  IsReadOnly As Boolean [read only]

  Keys As Object

  Put (Key As Object, Value As Object)

  Remove (Key As Object)

  Size As Int [read only]

  ToDictionary As Object

  Values As Object

Members description:

Clear
Removes all items from the Map.
ContainsKey (Key As Object) As Boolean
Returns true if there is an entry with the specified key.
Get (Key As Object) As Object
Returns the value tied to this key. Returns Null if no such key exists.
GetDefault (Key As Object, Default As Object) As Object
Returns the value tied to this key. Returns the Default parameter if no such key exists.
Initialize
Initializes the Map.
IsInitialized As Boolean [read only]
IsReadOnly As Boolean [read only]
In some cases libraries can return read only Maps. This property will return true for such maps.
Keys As Object
Can be used to iterate over the keys.
Example:
For Each key As String In Map1.Keys
Log("Value = " & Map1.Get(key))
Next
Put (Key As Object, Value As Object)
Puts the given key / value in the map. If there is already an entry with the same key then the previous entry will be removed.
Remove (Key As Object)
Removes the pair with the given key (if such exists).
Size As Int [read only]
Returns the number of elements in the collection.
ToDictionary As Object
Converts a Map to NSDictionary. This can be useful for interaction with native API.
Values As Object
Can be used to iterate over the values.
Top