代码之家  ›  专栏  ›  技术社区  ›  AZ_

Android:如何删除R.java中的旧引用?

  •  0
  • AZ_  · 技术社区  · 14 年前

    我对Android还不熟悉,对Android也不太了解。好吧,我已经创建了一个名为button-layout.xml的布局,并且第一次在button布局中添加了一个相对布局,并将其命名为too button layout。

    结果是它创建了R.java并用名称创建了对我的布局的引用 public static final int按钮布局=0x7f06000; 你们知道你们不能用 - 因为它是非法的。

    现在我想清理我的R.java有人知道这个问题的解决方案吗?

    在下面粘贴我的代码 button-layout.xml按钮

        <?xml version="1.0" encoding="UTF-8"?>
    <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent"
        xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/button-layout">
        <LinearLayout android:id="@+id/button-layout"
            android:layout_height="wrap_content" android:layout_width="fill_parent">
            <TextView android:id="@+id/TextView01"
                android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="First Name"></TextView>
            <EditText android:id="@+id/EditText01"
                android:layout_width="wrap_content" android:layout_height="wrap_content" android:width="100px"></EditText>
        </LinearLayout>
        <LinearLayout android:id="@+id/LinearLayout02"
            android:layout_below="@id/LinearLayout01" android:layout_width="wrap_content"
            android:layout_height="wrap_content">
            <TextView android:id="@+id/TextView02"
                android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Last Name"></TextView>
            <EditText android:id="@+id/EditText02"
                android:layout_width="wrap_content" android:layout_height="wrap_content" android:width="100px"></EditText>
        </LinearLayout>
        <LinearLayout android:id="@+id/LinearLayout03"
            android:layout_below="@id/LinearLayout02" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:layout_centerInParent="true">
            <Button android:id="@+id/Button01"
                android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Submit"></Button>
        </LinearLayout>
    </RelativeLayout>
    

    爪哇

    /* AUTO-GENERATED FILE.  DO NOT MODIFY.
     *
     * This class was automatically generated by the
     * aapt tool from the resource data it found.  It
     * should not be modified by hand.
     */
    
    package com.geniteam.mytest;
    
    public final class R {
        public static final class attr {
        }
        public static final class color {
            public static final int blue=0x7f050000;
        }
        public static final class drawable {
            public static final int golden_gate=0x7f020000;
            public static final int icon=0x7f020001;
        }
        public static final class id {
            public static final int Button01=0x7f060008;
            public static final int Button02=0x7f060010;
            public static final int EditText01=0x7f060003;
            public static final int EditText02=0x7f060006;
            public static final int LinearLayout01=0x7f060001;
            public static final int LinearLayout02=0x7f060004;
            public static final int LinearLayout03=0x7f060007;
            public static final int RelativeLayout01=0x7f06000e;
            public static final int TextView01=0x7f060002;
            public static final int TextView02=0x7f060005;
            public static final int backbutton=0x7f060014;
            public static final int btn_FNname=0x7f060011;
            public static final int btn_cancel=0x7f06000c;
            public static final int btn_shahzad=0x7f060012;
    

    public static final int button layout=0x7f06000;//这里有个错误

            public static final int editFirstName=0x7f060016;
            public static final int editLastName=0x7f060017;
            public static final int entry=0x7f06001a;
            public static final int firstName=0x7f060015;
            public static final int image=0x7f06000a;
            public static final int label=0x7f060019;
            public static final int lastName=0x7f060018;
            public static final int layout_root=0x7f060009;
            public static final int layout_shahzad=0x7f06000d;
            public static final int ok=0x7f06001b;
            public static final int relative_layout=0x7f060013;
            public static final int text=0x7f06000b;
            public static final int txt_label=0x7f06000f;
        }
        public static final class layout {
            public static final int abc=0x7f030000;
            public static final int custom_dialog=0x7f030001;
            public static final int frame_layout=0x7f030002;
            public static final int layout_shahzad=0x7f030003;
            public static final int main=0x7f030004;
            public static final int next_screen=0x7f030005;
            public static final int relative_layout=0x7f030006;
            public static final int relative_test_layout=0x7f030007;
        }
        public static final class string {
            public static final int app_name=0x7f040000;
            public static final int hello=0x7f040001;
            public static final int hello_new=0x7f040002;
        }
    }
    
    2 回复  |  直到 14 年前
        1
  •  4
  •   Raunak    14 年前

    java文件由资源编译器(AAPT)自动生成。因此,每次对项目进行更改并保存时,都会重新生成R.java文件。

        2
  •  4
  •   viv    14 年前

    当你构建你的项目时,java会被重新构建,如果它不删除它并重新构建。。。。