Java Android-getResources().getIdentifier()未找到资源

Java Android-getResources().getIdentifier()未找到资源,java,android,xml,view,Java,Android,Xml,View,我有一个xml文件,其中包含以下资源 <LinearLayout android:id="@+id/t214" android:padding="3dip"></LinearLayout> <LinearLayout android:id="@+id/t215" android:padding="3dip"></LinearLayout> 根据日志,id字符串变量的值为“t214”,因此getResources()。getIde

我有一个xml文件,其中包含以下资源

    <LinearLayout android:id="@+id/t214" android:padding="3dip"></LinearLayout>

    <LinearLayout android:id="@+id/t215" android:padding="3dip"></LinearLayout>
根据日志,id字符串变量的值为“t214”,因此getResources()。getIdentifier()应返回int标识符,以便可以在findViewById中使用,但ll将返回为null


非常感谢

我不确定我是否理解这个问题。。。但是,findViewById()的常规模式建议如下代码:


LinearLayout ll=(LinearLayout)findViewById(R.id.t214)

我不确定我是否理解这个问题。。。但是,findViewById()的常规模式建议如下代码:


LinearLayout ll=(LinearLayout)findViewById(R.id.t214)

您是否在创建函数中使用setcontentview?是的,setcontentview(R.layout.calendar\u view\u week);这就是包含视图的布局,我希望句柄正确。线性布局嵌套的事实是个问题吗?(它们嵌套在TableRow中)说我检查了R.java,所有的线性布局都在那里,我发现问题是由id中有数字的id引起的。这是不允许的吗?您是否在创建函数中使用setcontentview?是的,setcontentview(R.layout.calendar\u view\u week);这就是包含视图的布局,我希望句柄正确。线性布局嵌套的事实是个问题吗?(它们嵌套在TableRow中)说我检查了R.java,所有的线性布局都在那里,我发现问题是由id中有数字的id引起的。这是不允许的吗?
String id = "t" + c.get(Calendar.DAY_OF_WEEK) + c.get(Calendar.HOUR_OF_DAY);
Log.v("calendar", "id string: " + id);
// Get handle of LinearLayout
LinearLayout ll = (LinearLayout) findViewById(CalendarViewActivity.this.getResources().getIdentifier(id, "id", getPackageName()));