开发者

Layout can't be found

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜