Loading core/java/android/widget/ArrayAdapter.java +32 −13 Original line number Diff line number Diff line Loading @@ -37,19 +37,38 @@ import java.util.Comparator; import java.util.List; /** * A concrete BaseAdapter that is backed by an array of arbitrary * objects. By default this class expects that the provided resource id references * a single TextView. If you want to use a more complex layout, use the constructors that * also takes a field id. That field id should reference a TextView in the larger layout * resource. * * <p>However the TextView is referenced, it will be filled with the toString() of each object in * the array. You can add lists or arrays of custom objects. Override the toString() method * of your objects to determine what text will be displayed for the item in the list. * * <p>To use something other than TextViews for the array display, for instance, ImageViews, * or to have some of data besides toString() results fill the views, * override {@link #getView(int, View, ViewGroup)} to return the type of view you want. * You can use this adapter to provide views for an {@link 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 * {@link ListView} or {@link Spinner}. * <p> * By default, the array adapter creates a view by calling {@link Object#toString()} on each * data object in the collection you provide, and places the result in a TextView. * You may also customize what type of view is used for the data object in the collection. * To customize what type of view is used for the data object, * override {@link #getView(int, View, ViewGroup)} * and inflate a view resource. * For a code example, see * the <a href="https://developer.android.com/samples/CustomChoiceList/index.html"> * CustomChoiceList</a> sample. * </p> * <p> * For an example of using an array adapter with a ListView, see the * <a href="{@docRoot}guide/topics/ui/declaring-layout.html#AdapterViews"> * Adapter Views</a> guide. * </p> * <p> * For an example of using an array adapter with a Spinner, see the * <a href="{@docRoot}guide/topics/ui/controls/spinner.html">Spinners</a> guide. * </p> * <p class="note"><strong>Note:</strong> * If you are considering using array adapter with a ListView, consider using * {@link android.support.v7.widget.RecyclerView} instead. * RecyclerView offers similar features with better performance and more flexibility than * ListView provides. * See the * <a href="https://developer.android.com/guide/topics/ui/layout/recyclerview.html"> * Recycler View</a> guide.</p> */ public class ArrayAdapter<T> extends BaseAdapter implements Filterable, ThemedSpinnerAdapter { /** Loading Loading
core/java/android/widget/ArrayAdapter.java +32 −13 Original line number Diff line number Diff line Loading @@ -37,19 +37,38 @@ import java.util.Comparator; import java.util.List; /** * A concrete BaseAdapter that is backed by an array of arbitrary * objects. By default this class expects that the provided resource id references * a single TextView. If you want to use a more complex layout, use the constructors that * also takes a field id. That field id should reference a TextView in the larger layout * resource. * * <p>However the TextView is referenced, it will be filled with the toString() of each object in * the array. You can add lists or arrays of custom objects. Override the toString() method * of your objects to determine what text will be displayed for the item in the list. * * <p>To use something other than TextViews for the array display, for instance, ImageViews, * or to have some of data besides toString() results fill the views, * override {@link #getView(int, View, ViewGroup)} to return the type of view you want. * You can use this adapter to provide views for an {@link 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 * {@link ListView} or {@link Spinner}. * <p> * By default, the array adapter creates a view by calling {@link Object#toString()} on each * data object in the collection you provide, and places the result in a TextView. * You may also customize what type of view is used for the data object in the collection. * To customize what type of view is used for the data object, * override {@link #getView(int, View, ViewGroup)} * and inflate a view resource. * For a code example, see * the <a href="https://developer.android.com/samples/CustomChoiceList/index.html"> * CustomChoiceList</a> sample. * </p> * <p> * For an example of using an array adapter with a ListView, see the * <a href="{@docRoot}guide/topics/ui/declaring-layout.html#AdapterViews"> * Adapter Views</a> guide. * </p> * <p> * For an example of using an array adapter with a Spinner, see the * <a href="{@docRoot}guide/topics/ui/controls/spinner.html">Spinners</a> guide. * </p> * <p class="note"><strong>Note:</strong> * If you are considering using array adapter with a ListView, consider using * {@link android.support.v7.widget.RecyclerView} instead. * RecyclerView offers similar features with better performance and more flexibility than * ListView provides. * See the * <a href="https://developer.android.com/guide/topics/ui/layout/recyclerview.html"> * Recycler View</a> guide.</p> */ public class ArrayAdapter<T> extends BaseAdapter implements Filterable, ThemedSpinnerAdapter { /** Loading