ArrayAdapter() 构造函数中的第二个参数是什么?

What is the second argument in ArrayAdapter() constructor?

https://developer.android.com/guide/topics/ui/declaring-layout#FillingTheLayout

在这些文档中,我们有这个片段:

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
        android.R.layout.simple_list_item_1, myStringArray);

然后说构造函数的第二个参数是"The layout that contains a TextView for each string in the array."什么意思? "layout" 是什么意思?当我的数组可以是任意大小时,这样的布局怎么可能存在?这个布局是做什么用的?

What is meant by a "layout"?

指的是布局资源。布局资源包含在 the page that you linked to.

What is this layout used for?

它将用于 ListView 中的行,或 GridView 中的单元格,或其他内容,具体取决于 AdapterView 您在 ArrayAdapter 中使用的内容。

How can such a Layout exist when my array could be of any size?

布局资源将用于为数组中的单个项目提供 UI。根据需要,您的 ArrayAdapter 将使用布局资源创建 ListView 行。将其视为列表中单个行的模板。

这是关于如何组织项目的(比如 ListView)。您必须将 xml 文件的名称作为第二个参数传递,该参数将描述您是否希望列表项显示在 textArea、tableView 等中。