From d7ef95af6069fcbd563aa9862a3d931e569cb54e Mon Sep 17 00:00:00 2001 From: Joe Fernandez Date: Mon, 24 Apr 2017 13:50:13 -0700 Subject: [PATCH] docs: Update ArrayAdapter JavaDoc comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- core/java/android/widget/ArrayAdapter.java | 45 +++++++++++++++------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/core/java/android/widget/ArrayAdapter.java b/core/java/android/widget/ArrayAdapter.java index 869ef71c0d514..74f22b35e0019 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. - * - *

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

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}. + *

+ * 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 + * CustomChoiceList sample. + *

+ *

+ * For an example of using an array adapter with a ListView, see the + * + * Adapter Views guide. + *

+ *

+ * For an example of using an array adapter with a Spinner, see the + * Spinners guide. + *

+ *

Note: + * 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 + * + * Recycler View guide.

*/ public class ArrayAdapter extends BaseAdapter implements Filterable, ThemedSpinnerAdapter { /**