This is my current code, is their anyway that I can use some sort of loop to replace the copy paste? I am using Android Studio if that makes any difference.
if (otterPurchased >= 1) {
TableRow layoutOtter2 = (TableRow) findViewById(R.id.layoutOtter2);
layoutOtter2.setVisibility(View.VISIBLE);
if (otterPurchased >= 2) {
TableRow layoutOtter3 = (TableRow) findViewById(R.id.layoutOtter3);
layoutOtter3.setVisibility(View.VISIBLE);
if (otterPurchased >= 3) {
TableRow layoutOtter4 = (TableRow) findViewById(R.id.layoutOtter4);
layoutOtter4.setVisibility(View.VISIBLE);
if (otterPurchased >= 4) {
TableRow layoutOtter5 = (TableRow) findViewById(R.id.layoutOtter5);
layoutOtter5.setVisibility(View.VISIBLE);
if (otterPurchased >= 5) {
TableRow layoutOtter6 = (TableRow) findViewById(R.id.layoutOtter6);
layoutOtter6.setVisibility(View.VISIBLE);
if (otterPurchased >= 6) {
TableRow layoutOtter7 = (TableRow) findViewById(R.id.layoutOtter7);
layoutOtter7.setVisibility(View.VISIBLE);
if (otterPurchased >= 7) {
TableRow layoutOtter8 = (TableRow) findViewById(R.id.layoutOtter8);
layoutOtter8.setVisibility(View.VISIBLE);
if (otterPurchased >= 8) {
TableRow layoutOtter9 = (TableRow) findViewById(R.id.layoutOtter9);
layoutOtter9.setVisibility(View.VISIBLE);
if (otterPurchased >= 9) {
TableRow layoutOtter10 = (TableRow)
findViewById(R.id.layoutOtter10);
layoutOtter10.setVisibility(View.VISIBLE);
if (otterPurchased >= 10) {
TableRow layoutOtter11 = (TableRow) findViewById(R.id.layoutOtter11);
layoutOtter11.setVisibility(View.VISIBLE);
}
}
}
}
}
}
}
}
}
}
}
This just checks variables and runs the underneath code if true, also in a forever loop.