带有变量字符串的Android findViewbyId
我想创建如下内容:带有变量字符串的Android findViewbyId,android,Android,我想创建如下内容: TextView textView1= (TextView) dialog.findViewById(R.id.textView1); for(int i=0;i请参见。基本上,您需要类似以下内容: for (int i=0; i<100; i++) { TextView textView= (TextView) dialog.findViewById(R.id.textView+i); } for(int i=0;i for (int i=0; i<1
TextView textView1= (TextView) dialog.findViewById(R.id.textView1);
for(int i=0;i请参见。基本上,您需要类似以下内容:
for (int i=0; i<100; i++) {
TextView textView= (TextView) dialog.findViewById(R.id.textView+i);
}
for(int i=0;i
for (int i=0; i<100; i++) {
int resId = getResources().getIdentifier("textView" + i, "id", getPackageName());
TextView textView = (TextView) dialog.findViewById(resId);
}