@Override protected void doRestoreState(RestorableSupport rs, RestorableSupport.StateObject context) { super.doRestoreState(rs, context); RestorableSupport.StateObject so = rs.getStateObject(context, "layers"); if (so == null) return; RestorableSupport.StateObject[] lsos = rs.getAllStateObjects(so, "layer"); if (lsos == null || lsos.length == 0) return; ArrayList<Layer> layerList = new ArrayList<Layer>(lsos.length); for (RestorableSupport.StateObject lso : lsos) { if (lso != null) { Layer layer = new Layer(); layer.doRestoreState(rs, lso); layerList.add(layer); } } this.setLayers(layerList); }