I'm writing android app, which drawing 4 graphs in 1 plot. Graph data is stored in object GraphViewData(x,y). I also have List which contains 4 GraphVieData objects.
I want to give user ability to switch off/on some graphs.
I tried to write myList.set(index, null) to hide graph and then myList.set(index, myObject) to show it again, but every time the List size is changing. So I'm getting IndexOutOfBound exception.
Please, tell me why the List size is changing? Here is List.set() description:
Replaces the element at the specified location in this List with the
specified object. This operation does not change the size of the List.
Code:
public void removeSerie(int id){
graphSeries.set(id, null);
Log.d("CurrentListSize: ", graphSeries.size() + "");
}
public void addSerie(GraphViewData series, int id){
graphSeries.set(id, series);
}