/** Updates the gridLayout with the actual game data if existing. */ private void updateGridView() { if (fieldCreationFragment == null || fieldCreationFragment.getZahlenschlange() == null) { return; } Zahlenschlange gameLogic = fieldCreationFragment.getZahlenschlange(); int index = 0; for (int y = 0; y < difficulty; y++) { for (int x = 0; x < difficulty; x++) { View v = gameSquareGridLayout.getChildAt(index); if (v instanceof Field) { Field f = (Field) v; f.setNumber(gameLogic.getValue(x, y)); f.setDirection(Field.DIRECTION_NONE); f.setDirection2(Field.DIRECTION_NONE); f.setBodyStyle(Field.BODY_NORMAL); } index++; } } Field first = (Field) gameSquareGridLayout.getChildAt(0); Field last = (Field) gameSquareGridLayout.getChildAt(index - 1); first.setBodyStyle(Field.BODY_TAIL); last.setBodyStyle(Field.BODY_HEAD); drawPath(gameLogic.getPath()); }