Reputation: 4646
I am really not seeing the diffrence between ArrayAdapter and ArrayList... They both hold arrays, and do diffrent kinds of operations on them.. Its either that or i am not understanding ArrayAdapter Properly? Please help! Thankyou.
Upvotes: 1
Views: 7285
Reputation: 11
The Adapter acts as a bridge between the UI Component and the Data Source. It converts data from the data sources into view items that can be displayed into the UI Component. Data Source can be Arrays, HashMap, Database, etc. and UI Components can be ListView, GridView, Spinner, etc. ArrayAdapter is the most commonly used adapter in android. When you have a list of single-type items which are stored in an array you can use ArrayAdapter. Likewise, if you have a list of phone numbers, names, or cities. ArrayAdapter has a layout with a single TextView. If you want to have a more complex layout instead of ArrayAdapter use CustomArrayAdapter
Upvotes: 1
Reputation: 17171
ArrayList is an implementation of java.util.List that's backed by an array. You can use it anywhere you would use a java.util.List. E.g. where you need to maintain order of a collection of objects where duplicates are allowed.
ArrayAdapter is an Android SDK class for adapting an array of objects as a datasource. Adapters are used by Android to treat a result set uniformly whether it's from a database, file, or in-memory objects so that it can be displayed in a UI element. The ArrayAdapter is useful for the latter. Use it anywhere you would use an Adapter. E.g. attach to Android UI elements.
They both wrap an array, but not everything that wraps an array is the same. These two classes have very different goals, and they implement different interfaces.
Upvotes: 10