开发者

Layout can't be found

开发者 https://www.devze.com 2023-03-13 10:09 出处:网络
Wh开发者_开发知识库en I use the following line : LinearLayout layoutRoot = (LinearLayout) findViewById (R.id.layoutRoot);

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

精彩评论

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