I have a LinkedHashMap and I want to insert a List of Strings just to some of the 'headers' of my Expandable List, but for some reason I can't and I get the error
java.lang.IndexOutOfBoundsException: Invalid index 10, size is 1
LinkedHashMap <String, List<String>> expandableListDetail2 = new LinkedHashMap<String, List<String>>();
List<String> category_header = new ArrayList<String>();
List<Producto> produtos;
Database db = new Database(context);
List<Categorias> categories;
categories = db.getAllCategorias();
for (int i=0; i<categories.size(); i++){
expandableListDetail2.put(categories.get(i).toString(), category_header);
produtos = db.getAllProductos(categories.get(i).toString());
for(int j=0;j<produtos.size();j++) {
category_header.add(i, produtos.get(i).getNameProducto());
}
}
I'm getting error on the line where I have category_header.add(...) and all the products are been added to all keys. Can you help?
if (produtos.size() > 0)because the for loop checks it anyway.