Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ArrayAdapter.getPosition(item) Returns What?

I see the documentation says this method returns the position of the given item, but what would it return if no such item exists in the ArrayAdapter?

like image 296
user817129 Avatar asked Jul 16 '11 04:07

user817129


People also ask

What is Arrayadapter used for?

You can use this adapter to provide views for an AdapterView , Returns a view for each object in a collection of data objects you provide, and can be used with list-based user interface widgets such as ListView or Spinner .

What parameters does Arrayadapter take?

Parameters. The current context. This value can not be null. The resource ID for the layout file containing a layout to use when instantiating views.


1 Answers

After looking through the source code I've found that the ArrayAdapter uses List.indexOf(Object) to find the object and this method returns -1 when it doesn't exist.

GrepCode is awesome for finding stuff when the documentation is bad, I use it at least once a day :)

Source: GrepCode

like image 179
Nicklas A. Avatar answered Sep 27 '22 20:09

Nicklas A.