Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio can't find R.layout.simple_list_item_1, or any other default layout IDs

Tags:

android

IDs for things like R.layout.simple_list_item_1 don't show up on autocompletion in Android Studio. Nor can they be resolved when the name is typed in manually. I'm trying to use an ArrayAdapter, and I had to manually create a simple_list_item_1.xml in my project layout directory, and paste in the contents from the Android repository on Github

Am I missing something, or is that what's supposed to be done? Most resources I go to seem to just reference the list item XML without doing anything else

like image 580
Alex Avatar asked Jan 31 '15 16:01

Alex


2 Answers

to use android predefined layouts, colors etc. You should use

android.R.layout.simple_list_item_1

probably you try to reach your own resources. Check your imports and you should see your R file.

like image 115
Orhan Obut Avatar answered Oct 20 '22 18:10

Orhan Obut


as @Orhan Obut explained, use

android.R.layout.simple_list_item_1.

Do NOT leave out the word android in the above statement. That is how you access android's predefined resources

like image 39
Lone Ronin Avatar answered Oct 20 '22 17:10

Lone Ronin