Posts

Showing posts with the label android-arrayadapter

Text Size Change in Adapter class updates text size in all activities

Text Size Change in Adapter class updates text size in all activities The following is my WordAdapter class WordAdapter public class WordAdapter extends ArrayAdapter<Word> { /** Resource ID for the background color for this list of words */ private int mColorResourceId; /** * Create a new {@link WordAdapter} object. * * @param context is the current context (i.e. Activity) that the adapter is being created in. * @param words is the list of {@link Word}s to be displayed. * @param colorResourceId is the resource ID for the background color for this list of words */ public WordAdapter(Context context, ArrayList<Word> words, int colorResourceId) { super(context, 0, words); mColorResourceId = colorResourceId; } @Override public View getView(final int position, View convertView, ViewGroup parent) { // Check if an existing view is being reused, otherwise inflate the view View listItemView = convertView; if (listItemView == null) { listItemView =...

What is the second argument in ArrayAdapter() constructor?

What is the second argument in ArrayAdapter() constructor? https://developer.android.com/guide/topics/ui/declaring-layout#FillingTheLayout In these docs, we have this snippet: ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, myStringArray); It is then said that the second argument of the constructor is "The layout that contains a TextView for each string in the array." What does this mean? What is meant by a "layout"? How can such a Layout exist when my array could be of any size? What is this layout used for? TextView 1 Answer 1 What is meant by a "layout"? It is referring to a layout resource. Layout resources are covered in the page that you linked to. What is this layout used for? It will be used for rows in your ListView , or cells in your GridView , or other things depending on what AdapterView...