Wh开发者_开发知识库en I use the following line :
LinearLayout layoutRoot = (LinearLayout) findViewById (R.id.layoutRoot);
it gives an error saying that R.id.layoutRoot cannot be resolved.
what does it mean?
Verify that in your imports, you have something like:
import com.myproject.R
and not
import android.R
Check your R.java file
(which is in the gen directory) and you will see that the layouts identifiants don't belong to the id
class but the layout
class.
public static final class id {
}
public static final class layout {
// Layouts are here...
}
So it should be: R.layout.layoutRoot
.
Save the project
Exclude bin, gen from svn (if you use it)
Commit, update (if you use svn)
Clean
try to build again. If won't work:
Delete gen, bin
Save
Build.
精彩评论