diff options
| author | Joe Fernandez <joefernandez@google.com> | 2017-04-24 13:50:13 -0700 |
|---|---|---|
| committer | Joe Fernandez <joefernandez@google.com> | 2017-04-24 13:50:13 -0700 |
| commit | d7ef95af6069fcbd563aa9862a3d931e569cb54e (patch) | |
| tree | d344a1f53fa434d53e6a2ae6a1280ad70d15fc20 /core/java/android/widget/ArrayAdapter.java | |
| parent | 9870d0bef78949f0429de4f62532d98f2537c258 (diff) | |
docs: Update ArrayAdapter JavaDoc comments
update the introduction to:
- streamline wording by focusing on practical uses in introduction
- include crosslinks to relevant guides & examples
- a note about RecyclerView given it is mentioned in this context
- favor a p element with a note class applied
- incorporate reword via joe’s input on connecting topics
Test: Docs change only. Tested with doc build run.
Change-Id: I66511db5a978bff4e46d3d6080b00c2b7e6dfa64
Diffstat (limited to 'core/java/android/widget/ArrayAdapter.java')
| -rw-r--r-- | core/java/android/widget/ArrayAdapter.java | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/core/java/android/widget/ArrayAdapter.java b/core/java/android/widget/ArrayAdapter.java index 869ef71c0d51..74f22b35e001 100644 --- a/core/java/android/widget/ArrayAdapter.java +++ b/core/java/android/widget/ArrayAdapter.java @@ -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 { /** |
