Skip to content Skip to sidebar Skip to footer

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 understa

Solution 1:

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.

Solution 2:

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

Post a Comment for "What Is Arrayadapter?"