我是Android新手,我对Android不太了解。好吧,我创建了一个名为button-layout.xml的布局,首先我添加了一个相对布局,并将其命名为按钮布局。
它会创建R.java并创建一个名为 public static final int button-layout = 0x7f060000; 的布局引用,因为你知道你不能使用 - 在您的变量名称中,因为它是非法的。
现在我想清理我的R.java,任何人都知道这个问题的解决方案吗?
在下面粘贴我的代码 按钮-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>
R.java
/* 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 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;
}
}
答案 0 :(得分:4)
当您构建项目时,R.java会再次重建,因为它不会删除它并重新构建....
答案 1 :(得分:4)
R.java文件由资源编译器(AAPT)自动生成。因此,每次对项目进行更改并保存时,都会重建R.java文件。