Android设置linearLayout的id参数

Android设置linearLayout的id参数,android,android-layout,Android,Android Layout,我试图以编程方式将一些视图添加到已经在xml文件中定义的线性布局中 这是我定义LinearLayout的代码 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> 但是,正如您所看到的

我试图以编程方式将一些视图添加到已经在xml文件中定义的线性布局中

这是我定义LinearLayout的代码

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

但是,正如您所看到的,它没有id元素。如何添加一个,以便从活动中调用findviewbyd方法来检索布局?我尝试手动添加它,但它不是在R.java中生成的

谢谢

嗯,像这样吗

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/linearlayout1"
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical"> 

如果您添加了它并遇到问题,请尝试Project->Clean

如果所有其他操作都失败,请在gen->package目录中查找并核化R.java文件,以强制对其进行重建