I know you might have found your solution but just in case others couldn't find a proper one, i'll post mine here.
Let's say you labelled your "findViewById" like this:
<CheckBox
android:id="@+id/checkbox0"
android:layout_width="0dp"
android:layout_weight="1"
android:padding="5dip"/>
<CheckBox
android:id="@+id/checkbox1"
android:layout_width="0dp"
android:layout_weight="1"
android:padding="5dip"/>
.
.
.
<CheckBox
android:id="@+id/checkbox50"
android:layout_width="0dp"
android:layout_weight="1"
android:padding="5dip"/>
You can do something like this to "findViewById" using a few lines instead of
writing 50 "findViewById" lines:
CheckBox[] cb = new CheckBox[51];
for (int i = 0; i < 51; i++) {
String idCheckBox = "checkbox"+i;
cb[i] = (CheckBox) findViewById(YourActivity.this.getResources().getIdentifier(idCheckBox, "id", getPackageName()));
}
where "YourActivity.this" refers to the context.