Hier ist mein Problem hinzu:Wie Automodelle in Marke
Ich mag einige Autos hinzufügen, um seine Marke im Zusammenhang wie:
CADILLAC CTS, SRX, ESCALADE.
CHEVROLET: CAMARA, CORVETTE, VOLT.
ich eine Marke von Vehicule und Zugang zu wählenden Namen in Textview zu modellieren wie:
CADILLAC
-CTS
-SRX
-...
Was soll ich verwenden? Array?
Dank für die Antwort
EDIT: Hier ist mein eigentlicher Code, ist es Rotz für die Marke und Modelle, aber es war einfacher, so zu erklären ...
try
{
JSONArray QCM = response.getJSONArray("QCM");
for (int i = 0; i < QCM.length(); i++) {
JSONObject getQcmObject = QCM.getJSONObject(i);
//Récupère la question et la place dans un array
String questionGet = getQcmObject.getString("question");
questionArray.add(questionGet);
//Récupère les choix de la quesiton
JSONArray choiceGet = getQcmObject.getJSONArray("choix");
//Boucle qui permet d'ajouter les choix dans une listes
for (int x = 0; x < choiceGet.length(); x++) {
String choice = choiceGet.getString(x);
listOfChoice.add(choice);
System.out.println(listOfChoice);
}
multiMap.put(questionGet, listOfChoice);
listOfChoice.clear();
}
Set<Map.Entry<String, ArrayList<String>>> setMap = multiMap.entrySet();
// Get an iterator
Iterator<Map.Entry<String, ArrayList<String>>> iteratorMap = setMap.iterator();
System.out.println("\nHashMap with Multiple Values");
// display all the elements
while(iteratorMap.hasNext()) {
Map.Entry<String, ArrayList<String>> entry =
(Map.Entry<String, ArrayList<String>>) iteratorMap.next();
String key = entry.getKey();
List<String> values = entry.getValue();
System.out.println("Key = '" + key + "' has values: " + values);
}
}
ich nicht bekommen kann Zugang zu Wert! Hier ist meine Log-Katze
05-10 11:50:34.223 23881-23881/lyceraymondpointcar.entinfo I/System.out: Key = 'Combien d'os contient le squelette humain?' has values: []
05-10 11:50:34.223 23881-23881/lyceraymondpointcar.entinfo I/System.out: Key = 'Quel est la couleur du cheval blanc d'Henri IV?' has values: []
05-10 11:50:34.223 23881-23881/lyceraymondpointcar.entinfo I/System.out: Key = 'Une hernie inguinale étranglée :' has values: []
05-10 11:50:34.223 23881-23881/lyceraymondpointcar.entinfo I/System.out: Key = 'Lors des traumatismes de l'abdomen, le viscère le plus souvent touché est:' has values: []
05-10 11:50:34.223 23881-23881/lyceraymondpointcar.entinfo I/System.out: Key = 'Quelles sont les normes de la glycémie pré-pondial?' has values: []
05-10 11:50:34.223 23881-23881/lyceraymondpointcar.entinfo I/System.out: Key = 'Pathologies psychiatriques' has values: []
05-10 11:50:34.223 23881-23881/lyceraymondpointcar.entinfo I/System.out: Key = 'En fonction de l'agent vulnérant, les brûlures sont classées en quatre groupes. Lesquels?' has values: []
05-10 11:50:34.223 23881-23881/lyceraymondpointcar.entinfo I/System.out: Key = 'Dans le bilan pré-thérapeutique du cancer de l'endomètre, l'exploration la plus performante est:' has values: []
05-10 11:50:34.223 23881-23881/lyceraymondpointcar.entinfo I/System.out: Key = 'Dans la péritonite généralisée d'origine appendiculaire, lequel de ces signes est toujours absent?' has values: []
05-10 11:50:34.223 23881-23881/lyceraymondpointcar.entinfo I/System.out: Key = 'Les complications immédiates des brûlures électriques sont:' has values: []
05-10 11:50:34.223 23881-23881/lyceraymondpointcar.entinfo I/System.out: Key = 'Les myomes ont un effet délétère sur les paramètres de fertilité, s'ils sont:' has values: []
erste, müssen Sie 'Multimap cars' nicht' Multimap > cars' erstellen. Zweitens müssen Sie keine temrary 'listOfChoice'-Liste erstellen und die Modelle mit dem gleichen (Marken-) Schlüssel versehen:' multiMap.put (questionGet, choice); ' –
Wenn ich das tue, habe ich nur ein Modell in meinem Marke –
Ja, ein seltsames Verhalten von 'entrySet'. Dieser Code funktioniert gut: 'für (String brand: cars.keySet()) { für (String-Modell: cars.get (Marke)) { System.out.println (" Key = '"+ Marke +"' hat Werte: "+ Modell); } } ' –