Ich habe eine erweiterbare Listenansicht, und für jedes Kind, das ich brauche 4 „Extras“ haben oder Strings oder was auch immer es nennt: - childtitle - Beschreibung - link1 - link2hashmap innerhalb einer hashmap?
von einem Tutorial gefolgt, es war kein Problem, die Listenansicht, die verschiedenen Eltern und das Kind mit nur 1 String zu erstellen. Ich habe versucht, eine hashmap innerhalb einer hashmap zu erstellen, aber es hat nicht ganz funktioniert. Was ist eine bessere Lösung?
public void filldata(){
ArrayList productinfo = new ArrayList<>();
categories = new HashMap<>();
topics = new HashMap<>();
categories.add("FITNESS"); //This would be the parent title
categories.add("MONEY");
List<String> Fitness=new ArrayList<>();
List<String> Money=new ArrayList<>();
Fitness.add("Product1"); // this would be child1
List<String> Product1=new ArrayList<>();
Product1.add("desc1"); //this would be the description of child 1
Product1.add("link1.1");//this would be the link1 of child 1
Product1.add("link1.2");//this would be the link2 of child 1
Fitness.add("Product2"); //child2
Fitness.add("Product3"); //child3
Money.add("Product1"); //child 1
Money.add("Product2"); // " 2
Money.add("Product3"); // " 3
topics.put(categories.put(productinfo.get(0),Fitness)); //doesn't seem to work like this
categories.put(productinfo.get(1),Money);
}
Sie erhalten eher Hilfe, wenn Sie den tatsächlichen Text der Fehlermeldung in Ihre Fragen einfügen, anstatt nur Dinge wie "scheint nicht so zu funktionieren." –