android - I've tried everything and still can't solve the "R cannot be resolved to a variable" message -


setcontentview(r.layout.activity_main); 

gives me error message in title. i've tried delete , renerate r, clean project , nothing. activity_main right there registered in r. have no problems in /res, no red crosses or problems in problems tab. there's no import android.r in activity. i've tried find here , nothing. "r cannot resolved variable"?

what's going on?

the simplest coding pattern, , see examples do, have activities (and other resource-dependent classes) reside in java package declared in manifest's package attribute. way, r auto-imported, , don't have think it.

you welcome have r references in other packages, have import r manifest's package (e.g., import com.commonsware.sample.r;).


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -