Java 是否可以通过ID循环到findViewById android

Java 是否可以通过ID循环到findViewById android,java,android,xml,findviewbyid,Java,Android,Xml,Findviewbyid,我在GUI上创建了一个表,但我一直在循环视图的ID,因为它不是路径中的字符串。请帮助任何人 例如,ID是tMon9、tMon10、tMon11等 String classgroup = "CO.DNET3"; int semester = 2; Timetable t = null; try { t = new Timetable(classgroup, semester); } catch (IOException e) {

我在GUI上创建了一个表,但我一直在循环视图的ID,因为它不是路径中的字符串。请帮助任何人

例如,ID是tMon9、tMon10、tMon11等

    String classgroup = "CO.DNET3";
    int semester = 2;

    Timetable t = null;
    try {
        t = new Timetable(classgroup, semester);


    } catch (IOException e) {
        e.printStackTrace();
    }


    if(t!=null)
    {
        TextView tv;
        for (int i = 9; i < 18; i++) {
            if (t.getModule("wednesday", i + ":00") != null) {


                tv=(TextView)findViewById(R.id. (LOOP HERE)    ); // I want to loop through ids

                String s = "";
                s+= t.getModule("wednesday", i + ":00") + "\n";
                s+= t.getRoomNumber("wednesday", i + ":00") + "\n";
                tv.setText(s);
            }
        }
    }
String classgroup=“CO.DNET3”;
int学期=2;
时刻表t=null;
试一试{
t=新时间表(班级、学期);
}捕获(IOE异常){
e、 printStackTrace();
}
如果(t!=null)
{
文本视图电视;
对于(int i=9;i<18;i++){
如果(t.getModule(“星期三”,i+“:00”)!=null){
tv=(TextView)findViewById(R.id.(在这里循环));//我想通过id循环
字符串s=“”;
s+=t.getModule(“星期三”,i+“:00”)+“\n”;
s+=t.getRoomNumber(“星期三”,i+“:00”)+“\n”;
tv.setText(s);
}
}
}

使用
getIdentifier
使用字符串名称获取视图id:

int textViewID = getResources().getIdentifier("tMon"+i, "id", getPackageName());
tv=(TextView)findViewById(textViewID);