Search code examples
javaandroidarraylistandroid-arrayadapter

What Is ArrayAdapter?


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.


Solution

  • 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.