Exam AND-401 All QuestionsBrowse all questions from this exam
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 arrayAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, items); listView.setAdapter(arrayAdapter);

    Correct Answer: A

    ArrayAdapter is used to adapt an array of data (in this case, strings) into views that can be displayed in a ListView. Specifically, ArrayAdapter uses a specified layout (here, android.R.layout.simple_list_item_1) to create a view for each item in the array. The layout android.R.layout.simple_list_item_1 contains a TextView, so the ArrayAdapter will create a TextView for each String in the array items.

Discussion
MmadiOption: A

A. It creates a TextView for each String in array items.