Android Application Development (AND-401) — Question 36

Which of the following is true about object arrayAdapter declared in the code below?
String[] items = {"Item 1","Item 2","Item 3"};
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items); listView.setAdapter(arrayAdapter);

Answer options

Correct answer: A

Explanation

The correct answer is A because the ArrayAdapter is designed to create a TextView for each item in the provided String array. Options B and D are incorrect as the ArrayAdapter does not create Buttons or replace the layout of the activity. Option C is also wrong since it only creates three views corresponding to the three items in the array.