2011-06-14 65 views
0

當我使用下面的行:佈局無法找到

LinearLayout layoutRoot = (LinearLayout) findViewById (R.id.layoutRoot); 

它提供了一個錯誤,說R.id.layoutRoot cannot be resolved.

這是什麼意思?

+0

你能告訴我們你得到的確切錯誤以及你在調用setContentView()的代碼中的位置嗎? – plowman 2011-06-14 17:07:15

+0

查看內容= findViewById(R.layout.layoutRoot); 位圖位圖= content.getDrawingCache();這是代碼,基本上我想拍攝屏幕並保存。 – Vaali 2011-06-15 04:52:52

回答

0

檢查R.java file(這是在目錄),你將看到的佈局identifiants不屬於id類,但layout類。

public static final class id { 

    } 
    public static final class layout { 
     // Layouts are here... 
    } 

所以它應該是:R.layout.layoutRoot

+0

我看了一下佈局類,它的deosnt裏面有layoutroot – Vaali 2011-06-15 04:55:33

+0

你真的有一個叫layoutRoot.xml的佈局嗎? – 2011-06-15 08:07:01

1

驗證在你的進口,你有這樣的:

import com.myproject.R 

,而不是

import android.R 
0

保存項目(如果您使用它)
排除斌,創自SVN
提交,更新(如果你使用svn)
Clean

嘗試再次構建。如果將不起作用:

刪除根,倉
保存

生成。