What is "android.R.layout.simple_list_item_1"?

Zakaria picture Zakaria · Sep 8, 2010 · Viewed 230.2k times · Source

I've started learning Android development and am following a todolist example from a book:

// Create the array list of to do items
final ArrayList<String> todoItems = new ArrayList<String>();

// Create the array adapter to bind the array to the listView
final ArrayAdapter<String> aa;
aa = new ArrayAdapter<String>(  this, 
                                android.R.layout.simple_list_item_1,
                                todoItems
                            );
myListView.setAdapter(aa);

I can't understand exactly this code especially this line:

android.R.layout.simple_list_item_1

Answer

Kevin Coppock picture Kevin Coppock · Sep 8, 2010

Zakaria, that is a reference to an built-in XML layout document that is part of the Android OS, rather than one of your own XML layouts.

Here is a further list of layouts that you can use: http://developer.android.com/reference/android/R.layout.html
(Updated link thanks @Estel: https://github.com/android/platform_frameworks_base/tree/master/core/res/res/layout )

You can actually view the code for the layouts.