问题描述
我跟着信
但是,下面的行产生一个com.example.helloandroid.R.id解决不了错误:
Yet, the following line produces a "com.example.helloandroid.R.id cannot be resolved" error:
mView = (TextView) mActivity.findViewById(com.example.helloandroid.R.id.textview);
Eclipse的惊人建议2快速修复:
Eclipse amazingly suggests 2 quick fixes:
- 在式'R'创建领域'ID'
- 创建类型常量'ID''R'
你能帮助我理解这些修复的意思吗?难道这些真的是正确的修正? (为什么没有教程提供给他们,太?)
Can you help me understand what these fixes mean? Are these really the correct fixes? (why didn't the tutorial provide them, too?)
推荐答案
在HelloAndroid项目,HelloAndroid.java
In HelloAndroid project, HelloAndroid.java
setContentView(R.layout.main);
检查您的HelloAndroid项目中,广播> com.example.helloandroid-> R.java有下列code,如:
Check your HelloAndroid project, in "gen->com.example.helloandroid->R.java" have the following code like:
public static final class id {
public static final int textview=0x7f050000;
}
如果没有,勾选水库 - >布局 - > main.xml中。有机器人:ID =?@ + ID /如下TextView的
if no, check "res->layout->main.xml". there is "android:id="@+id/textview" as follows?
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="@string/hello"/>
检查这些项目,如果需要修复您的HelloAndroid.java和/或main.xml中。
重建HelloAndroid项目,并重建HelloAndroidTest项目。
check these items, fix your HelloAndroid.java and/or main.xml if needed.rebuild HelloAndroid project, and rebuild HelloAndroidTest project.
这篇关于com.example.helloandroid.R.id不能得到解决的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!