I had problems with resolving R several times after I added new layout XML files. I use Eclipse and API 8. Sometimes it goes away after I “clean” the project, or close and then reopen the project. I tried to add “import android.R” but it didn’t help. Someone said that this is because some layout XML files have errors, but the file looks right to me.
Here is an XML file, res/layout/status.xml, that I had problems with:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button android:text="Button" android:id="@+id/button_tmp" android:layout_height="wrap_content" android:layout_width="wrap_content"></Button>
</LinearLayout>
and here is how I use it:
public class StatusActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.status);
}
}
One more thing, this XML file has a question mark in the “Package Explore” panel in Eclipse, but the main.xml has a different icon. I have only two layout XML files now.
Do I need to do something special in Eclipse to add a new layout XML file?
Thanks for your help!
Update a screenshot of icons in the “Package Explore” panel:

Finally figured it out. There is nothing wrong with the layout XML file. The problem is that the
StatusActivityclass is not in the top-level package, but the R class auto-generated is in the top-level package. So inStatus.java, I need to import it, but in the main activity class, which is in the top-level package, I don’t. That’s whymain.xmlworks butstatus.xmldoes not.As for the different icon, it indicate if this file is managed by the SCM system. Since
status.xmlis new, so it has a question mark.