Skip to content Skip to sidebar Skip to footer

Why Is My Custom Layout File Not Recognized?

I created a file in \res\layout named contactlist.xml But it is not recognized in my code: SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this, //android.R.layout.s

Solution 1:

It should be

R.layout.contactlist

and not

android.R.layout.contactlist

android is used when you are using the system resources.

Solution 2:

use your application generated R file(R.layout.contactlist) rather than using android generated R file(android.R.layout.contactlist).

Solution 3:

If you are using Eclipse, I think you should try re-start Eclipse. Sometimes, when i add new xml or delete some, my eclipse's not smart enough, i don't know why. There are other ways like Clean Project(But you have to make sure that there is No Error in your XML, otherwise your R will gone forever).

Not quite sure, hope it help

Solution 4:

I think u missed setContentView(R.Layout.contactlist);...also u need to specify this in your manifest.

Solution 5:

Sometimes, even when you replace the android.R.layout.zzz with R.layout.zzz, Eclipse will still show you an error that your customer layout is no recognized.

I just faced this same problem now.

The solution for me was to remove that text and write it again. You may also write it gradually by writing "R." then pressing Alt+Space, Eclipse will give you 2 options (android.R and R.), just pick the R. and then continue the rest.

Post a Comment for "Why Is My Custom Layout File Not Recognized?"