findViewById看不到我的EditText的id

时间:2014-04-09 13:21:19

标签: java android findviewbyid

我有EditText()

<EditText
            android:id="@+id/СA_EtFirN"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:hint="@string/CA_EtFirN"
            android:textColor="@color/SSA_TvColor"
            android:textStyle="italic"
            android:layout_gravity="center"
            android:gravity="center_horizontal"/>

所以当你看到android:id="@+id/СA_EtFirN"时。然后我有一个Activity.java,我想定义我的EditText()

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.contacts);

    Log.i(TAG, "Start definition");
    tv1 = (TextView) findViewById(R.id.CA_Tv1);
    et1 = (EditText) findViewById(R.id.CA_EtFirN);
}

但是CA_EtFirN标有红色下划线。所以我的程序没有看到它。有什么想法吗?

我的R.id

public final class R {
public static final class array {
    public static final int SSA_Sp=0x7f070000;
}
public static final class attr {
}
public static final class color {
    public static final int CA_BgColor=0x7f060005;
    public static final int CA_TvColor=0x7f060006;
    public static final int CGA_BgColor=0x7f060007;
    public static final int CGA_TvColor=0x7f060008;
    public static final int MA_BgColor=0x7f060001;
    public static final int MA_TvColor=0x7f060000;
    public static final int SSA_BgColor=0x7f060002;
    public static final int SSA_SpColor=0x7f060004;
    public static final int SSA_TvColor=0x7f060003;
}
public static final class dimen {
    /**  Default screen margins, per the Android Design guidelines. 

     Customize dimensions originally defined in res/values/dimens.xml (such as
     screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.

     */
    public static final int activity_horizontal_margin=0x7f040000;
    public static final int activity_vertical_margin=0x7f040001;
}
public static final class drawable {
    public static final int ic_launcher=0x7f020000;
    public static final int pic_congrat_activity=0x7f020001;
}
public static final class id {
    public static final int CA_BtnAutoAdd=0x7f0a000d;
    public static final int CA_BtnHardAdd=0x7f0a000b;
    public static final int CA_Tv1=0x7f0a0003;
    public static final int CA_Tv2=0x7f0a000c;
    public static final int CGA_IV=0x7f0a0002;
    public static final int CGA_Tv1=0x7f0a0000;
    public static final int CGA_TvDays=0x7f0a0001;
    public static final int MA_BtnCont=0x7f0a0011;
    public static final int MA_BtnSet=0x7f0a0012;
    public static final int MA_Tv1=0x7f0a000e;
    public static final int MA_Tv2=0x7f0a0010;
    public static final int MA_TvDays=0x7f0a000f;
    public static final int SSA_BtnCont=0x7f0a001c;
    public static final int SSA_BtnFemale=0x7f0a001f;
    public static final int SSA_BtnMale=0x7f0a001e;
    public static final int SSA_ETDay=0x7f0a0014;
    public static final int SSA_ETMonth=0x7f0a0008;
    public static final int SSA_ETYear=0x7f0a000a;
    public static final int SSA_RbHun=0x7f0a0017;
    public static final int SSA_RbTen=0x7f0a0016;
    public static final int SSA_Tv1=0x7f0a0013;
    public static final int SSA_Tv2=0x7f0a0015;
    public static final int SSA_Tv3=0x7f0a0019;
    public static final int SSA_Tv4=0x7f0a001a;
    public static final int SSA_Tv5=0x7f0a001d;
    public static final int SSA_TvDot1=0x7f0a0007;
    public static final int SSA_TvDot2=0x7f0a0009;
    public static final int SSA_TvSel=0x7f0a001b;
    public static final int SSS_RbTho=0x7f0a0018;
    public static final int action_settings=0x7f0a0020;
    public static final int СA_ETDay=0x7f0a0006;
    public static final int СA_ETSecondName=0x7f0a0005;
    public static final int СA_EtFirN=0x7f0a0004;
}
public static final class layout {
    public static final int congrat=0x7f030000;
    public static final int contacts=0x7f030001;
    public static final int eighth_march=0x7f030002;
    public static final int main=0x7f030003;
    public static final int start_set=0x7f030004;
    public static final int twenty_third_feb=0x7f030005;
}
public static final class menu {
    public static final int main=0x7f090000;
}
public static final class string {
    public static final int CA_BtnAdd=0x7f050018;
    public static final int CA_BtnAutoAdd=0x7f050021;
    public static final int CA_BtnHardAdd=0x7f050020;
    public static final int CA_ETDays=0x7f05001d;
    public static final int CA_ETMonth=0x7f05001e;
    public static final int CA_ETYear=0x7f05001f;
    public static final int CA_EtFirN=0x7f05001b;
    public static final int CA_EtSecN=0x7f05001c;
    public static final int CA_Tv1=0x7f050019;
    public static final int CA_Tv2=0x7f05001a;
    public static final int CGA_Tv1=0x7f050022;
    public static final int MA_BtnCont=0x7f050006;
    public static final int MA_BtnSet=0x7f050007;
    public static final int MA_Tv1=0x7f050003;
    public static final int MA_Tv2=0x7f050005;
    public static final int MA_TvDays=0x7f050004;
    public static final int SSA_BtnCont=0x7f050010;
    public static final int SSA_BtnFemale=0x7f05000f;
    public static final int SSA_BtnMale=0x7f05000e;
    public static final int SSA_ETDays=0x7f050011;
    public static final int SSA_ETMonth=0x7f050012;
    public static final int SSA_ETYear=0x7f050013;
    public static final int SSA_RbHun=0x7f050016;
    public static final int SSA_RbTen=0x7f050015;
    public static final int SSA_RbTho=0x7f050017;
    public static final int SSA_Tv1=0x7f050008;
    public static final int SSA_Tv2=0x7f050009;
    public static final int SSA_Tv3=0x7f05000a;
    public static final int SSA_Tv4=0x7f05000b;
    public static final int SSA_Tv5=0x7f05000d;
    public static final int SSA_TvDot=0x7f050014;
    public static final int SSA_TvSel=0x7f05000c;
    public static final int action_settings=0x7f050001;
    public static final int app_name=0x7f050000;
    public static final int hello_world=0x7f050002;
}

P.S使用TextView即可。

4 个答案:

答案 0 :(得分:3)

尝试将layout.xml中的id复制/粘贴到代码中(反之亦然),以确保您没有在名称中混合使用西里尔字符和拉丁字符。

答案 1 :(得分:2)

尝试清理项目并重建,有时候R.java没有很好地更新。

答案 2 :(得分:2)

这很奇怪))如果我复制CA_EtFirN就可以了。但是,如果我写了id的名字(同名,我已经检查!!!)这是一个错误)

答案 3 :(得分:1)

在java类中检查import语句android.R 如果存在则删除该导入语句,然后清理项目,然后再次运行并对结果进行评论