In fact, I've added only two lines:
if (xmlRes != -1) {
grid.setBackgroundResource(xmlRes);
}
but so many changes applied because of auto-reformatting code in IntelliJ IDEA.
If we do not check xmlRes, it produces exception: Caused by: android.content.res.Resources$NotFoundException: Resource ID #0xffffffff
In fact, I've added only two lines: if (xmlRes != -1) { grid.setBackgroundResource(xmlRes); } but so many changes applied because of auto-reformatting code in IntelliJ IDEA. If we do not check xmlRes, it produces exception: Caused by: android.content.res.Resources$NotFoundException: Resource ID #0xffffffff