Sunday, March 10, 2019

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

Sometimes you will find some predefined layout in other examples, such as android.R.layout.simple_list_item_1 like this:

        String[] suggestion = getResources().getStringArray(R.array.suggestion);
        ArrayAdapter<String> adapter =
                new ArrayAdapter<String>(this,
                        android.R.layout.simple_list_item_1, suggestion);

It's a reference to built-in XML layout that is part of the Android OS, HERE. Basically, all reference start with android.R is reference to Android built-in resource.

You can locate the source file in your development setup from Android Studio (BUT DON'T EDIT IT):


> Select it and right click > Go to > Declaration
Android Studio will open it for you, and the location will be shown on top bar.


No comments:

Post a Comment