Quiz Programmierung

M

MrYouMath

Neues Mitglied
0
Hi Leute,

ich bin ein absoluter Programmierneuling, darum bitte ich um Geduld:).
Ich versuche eine Quiz App zu programmieren. Ich schildere meine Grundidee.
Ich will ein kleines Mathe Quiz machen, bei dem man eine Formel als Bild angezeigt bekommt. Der User muss dann eines der Buttons anklicken, welches den Richtigen Namen der Formel enthält.
Bilder und Namen der Formeln sollen in Datenbank gespeichert werden.

Sobald das Spiel beginnt wird eine Funktion play() ausgeführt.

Hier werden erst Variablen deklariert, initialisiert und weiterhin wird ein
ButtonArray erstellt.
Code:
Button[] choice = {(Button) findViewById (R.id.choice1),
	    		  (Button) findViewById (R.id.choice2),
	    		  (Button) findViewById (R.id.choice3),
	    		  (Button) findViewById (R.id.choice4)};

diese besteht eigentlich aus eine for(int i = 0; i < AnzahlRunden; i++){...}
Zuerst werden in jedem Durchgang vier Positionen geshuffelt und dann vier einzigartige Zahlen randomisiert ausgewählt(Formel IDs um aus der Datenbank ebendiese zu ziehen).

Das was ich dann versuche ist die Auswahl-Buttons aus der XML mit neuem Text zu beschreiben.

Code:
choice[positions.get(0) - 1].setText(names[idValues.get(0)]);
choice[positions.get(1) - 1].setText(names[idValues.get(1)]);
choice[positions.get(2) - 1].setText(names[idValues.get(2)]);
choice[positions.get(3) - 1].setText(names[idValues.get(3)]);

Komischerweise startet der Emulator ohne Problem, aber einerseits werden die ButtonTexte nicht geändert andererseits hängt sich das Programm auf sobald ich einen Button klicke.
Blöd ist das mir Eclipse keinen Hinweis darauf gibt was das Problem ist.

Kennt einer von euch evtl. ein Beispiel-Projekt für ein Quiz? Dann könnte ich mal schauen was ich da nicht richtig gemacht habe.

Bin dankbar für jeden Hinweis.
 
Standardfehler :D

findViewById funktioniert erst, nachdem (zeitlich gesehen!) man setContentView aufgerufen hat.
 
Im Logcat findest du ganz sicher einen Hinweis auf den Fehler.

choice[positions.get(0) - 1] macht mich aber auch stutzig, bist du sicher, daß das stimmt? Das get(0) ist liefert doch bestimmt das 1. Element, wenn du dann noch 1 abziehst gehts womöglich ins Leere ;-)
 
@DieGoldeneMitte:
also ich habe erst
setContentView(R.layout.play);
und dann
play();
in der Funktion play() steckt dann auch meine findViewById. Wie soll ich das denn sonst machen? Hmm ... ich zieh mal das setContentView(R.layout.play); auch in die Funktion play. Hast du das so gemeint?


@Tom299:
choice[positions.get(0)-1] ist eigentlich so richtig. positions ist eine ArrayList mit
vier werten 1,2,3,4. Darum ziehe ich eins ab da ich sonst bei dem choice Array nicht auf dem richtigen Button landen würde.
Mit LogCat hast du recht, aber da verstehe ich nur Bahnhof. Das ist viel zu komplex.

Hier die LogCat ausgabe:
Code:
07-03 13:13:23.264: I/Process(226): Sending signal. PID: 226 SIG: 9
07-03 13:13:26.294: D/dalvikvm(233): GC freed 537 objects / 47792 bytes in 79ms
07-03 13:13:28.824: D/dalvikvm(233): GC freed 1787 objects / 96232 bytes in 69ms
07-03 13:13:28.904: D/AndroidRuntime(233): Shutting down VM
07-03 13:13:28.904: W/dalvikvm(233): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
07-03 13:13:28.904: E/AndroidRuntime(233): Uncaught handler: thread main exiting due to uncaught exception
07-03 13:13:28.954: E/AndroidRuntime(233): java.lang.IllegalStateException: Could not execute method of the activity
07-03 13:13:28.954: E/AndroidRuntime(233): 	at android.view.View$1.onClick(View.java:2031)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at android.view.View.performClick(View.java:2364)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at android.view.View.onTouchEvent(View.java:4179)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at android.widget.TextView.onTouchEvent(TextView.java:6541)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at android.view.View.dispatchTouchEvent(View.java:3709)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at android.os.Handler.dispatchMessage(Handler.java:99)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at android.os.Looper.loop(Looper.java:123)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at android.app.ActivityThread.main(ActivityThread.java:4363)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at java.lang.reflect.Method.invoke(Method.java:521)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at dalvik.system.NativeStart.main(Native Method)
07-03 13:13:28.954: E/AndroidRuntime(233): Caused by: java.lang.reflect.InvocationTargetException
07-03 13:13:28.954: E/AndroidRuntime(233): 	at com.quiz.hero.QuizActivity.actionButtonPlay(QuizActivity.java:88)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at java.lang.reflect.Method.invoke(Method.java:521)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at android.view.View$1.onClick(View.java:2026)
07-03 13:13:28.954: E/AndroidRuntime(233): 	... 21 more
07-03 13:13:28.954: E/AndroidRuntime(233): Caused by: java.lang.IndexOutOfBoundsException
07-03 13:13:28.954: E/AndroidRuntime(233): 	at java.util.ArrayList.set(ArrayList.java:580)
07-03 13:13:28.954: E/AndroidRuntime(233): 	at com.quiz.hero.QuizActivity.play(QuizActivity.java:152)
07-03 13:13:28.954: E/AndroidRuntime(233): 	... 25 more
07-03 13:13:28.994: I/dalvikvm(233): threadid=7: reacting to signal 3
07-03 13:13:29.004: I/dalvikvm(233): Wrote stack trace to '/data/anr/traces.txt'
07-03 13:13:31.984: I/Process(233): Sending signal. PID: 233 SIG: 9
 
Zuletzt bearbeitet:
Die IndexOutOfBoundsException deutet darauf hin das du versuchst mit einem Index auf ein Array zuzugreifen der ausserhalb des gültigen Bereichs liegt.
 
hmm ... kann es sein, dass der Index von ArrayList bei 1 anfängt und nicht bei 0?
 
Nein der geht von 0 bis size()-1.
Zeig doch mal den part wo du positions.set(....) benutzt. Die Exception wird nämlich in ArrayList.set() geworfen.
 
Was ist denn position überhaupt? :D
Es müsste ja eigentlich, einfach dargestellt, so ausshene:
choice[0].setText("aklsdjak")
usw

Mach doch mal:
System.out.println(positions.get(0) - 1);

Dann siehst du ja ob 0 raus kommt oder nicht. Ansonsten mal -1 weg machen und +4 xD
 
@IceClaw: Ich brauche die Positions weil ich eine randomisierte Zuordnung zu den Buttons machen will. Ich habe die -1 weggelassen,
aber nix passiert.

@strider: Also hier setze ich positions fest.
Code:
// numbers from 1 to 4 to hold positions
  // declaration of ArrayList with integer values
     ArrayList<Integer> positions = new ArrayList<Integer>();
  // initialisation from 1 to 4
     for (int i = 0 ; i < 4 ; i++){positions.set(i, i+1);}
  // shuffles the ArrayList numbers
     Collections.shuffle(positions);
und hier setze ich die id's fest:
Code:
// numbers to hold IDs of possible answers
// declaration of ArrayList with integer values
  ArrayList<Integer> idValues = new ArrayList<Integer>();
// initialsation with starting values unique id values
  do{
    // assigns random number to i.index of idValues
      for (int i = 0 ; i < 4 ; i++){idValues.set(i, ((rand.nextInt() % MAXID) +1) );}
    // boolean to check if idValues are unique
      uniqueness = !(((idValues.get(0) == idValues.get(1)) ||
			    (idValues.get(0) == idValues.get(2)) ||
			    (idValues.get(0) == idValues.get(3)) ||
			    (idValues.get(1) == idValues.get(2)) ||
			    (idValues.get(1) == idValues.get(3)) ||
			    (idValues.get(2) == idValues.get(3))));
  }while(uniqueness == false);
    // shuffles the ArrayList idValues;
      Collections.shuffle(idValues);
 
Zuletzt bearbeitet:
Ok das ist es.
Das Problem ist das set() nicht auf leere Elemente funktioniert damit kannst du nur Elemente verändern die schon in der ArrayList drin sind. Und zu dem Zeitpunkt ist die ArrayList leer. Füg die Elemente mit add() hinzu.
 
Das hört sich plausibel an, ich habe das mal geändert:). Jetzt warte ich auf den Emulator O_O.

Update kommt gleich :).
EDIT: Das Ding spinnt jetzt total rum. Habe es neu gestartet und immer noch das Gleiche Problem.
Ich poste mal die Funktion play();

Code:
 public void play(){
    	
    	setContentView(R.layout.play);
    	
    	Random rand = new Random();
    	int actualRound = 1;
    	Button[] choice = {(Button) findViewById (R.id.choice1),
				   (Button) findViewById (R.id.choice2),
				   (Button) findViewById (R.id.choice3),
				   (Button) findViewById (R.id.choice4)};
    	String []names = {"john","don","ron","kon","lon"};
    	//
    	for (int j = 0; j < ROUNDS ; j++){
    	
	    	boolean uniqueness = false;
	    	actualRound = j+1;
	    	score = 0;
	    	
	    	
	    	// numbers from 1 to 4 to hold positions
		    	// declaration of ArrayList with integer values
		    	ArrayList<Integer> positions = new ArrayList<Integer>();
		    	// initialisation from 1 to 4
		    	for (int i = 0 ; i < 4 ; i++){positions.add(i+1);}
		    	// shuffles the ArrayList numbers
		    	Collections.shuffle(positions);
		  
		    
		    // numbers to hold IDs of possible answers
		    	// declaration of ArrayList with integer values
		    	ArrayList<Integer> idValues = new ArrayList<Integer>();
		    	// initialsation with starting values unique id values
		    	for (int i = 0 ; i < 4 ; i++){idValues.add(i+1);}
		    	do{
		    		// assigns random number to i.index of idValues
		    		for (int i = 0 ; i < 4 ; i++){idValues.set(i, ((rand.nextInt() % MAXID) +1) );}
		    		// boolean to check if idValues are unique
		    		uniqueness = !(((idValues.get(0) == idValues.get(1)) ||
			    				    (idValues.get(0) == idValues.get(2)) ||
			    				    (idValues.get(0) == idValues.get(3)) ||
			    				    (idValues.get(1) == idValues.get(2)) ||
			    				    (idValues.get(1) == idValues.get(3)) ||
			    				    (idValues.get(2) == idValues.get(3))));
		    	}while(uniqueness == false);
		    	// shuffles the ArrayList idValues;
		    	Collections.shuffle(idValues);
		    	
		    	choice[positions.get(0)].setText(names[idValues.get(0)]);
	    		choice[positions.get(1)].setText(names[idValues.get(1)]);
	    		choice[positions.get(2)].setText(names[idValues.get(2)]);
	    		choice[positions.get(3)].setText(names[idValues.get(3)]);
    	}


Und hier der LogCat.
Code:
07-03 14:03:02.859: D/ddm-heap(223): Got feature list request
07-03 14:03:03.070: D/dalvikvm(223): GC freed 515 objects / 46960 bytes in 104ms
07-03 14:10:34.020: D/dalvikvm(249): GC freed 537 objects / 47792 bytes in 82ms
07-03 14:10:43.459: D/dalvikvm(249): GC freed 1791 objects / 96432 bytes in 71ms
07-03 14:10:43.539: D/AndroidRuntime(249): Shutting down VM
07-03 14:10:43.550: W/dalvikvm(249): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
07-03 14:10:43.550: E/AndroidRuntime(249): Uncaught handler: thread main exiting due to uncaught exception
07-03 14:10:43.579: E/AndroidRuntime(249): java.lang.IllegalStateException: Could not execute method of the activity
07-03 14:10:43.579: E/AndroidRuntime(249): 	at android.view.View$1.onClick(View.java:2031)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at android.view.View.performClick(View.java:2364)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at android.view.View.onTouchEvent(View.java:4179)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at android.widget.TextView.onTouchEvent(TextView.java:6541)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at android.view.View.dispatchTouchEvent(View.java:3709)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at android.os.Handler.dispatchMessage(Handler.java:99)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at android.os.Looper.loop(Looper.java:123)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at android.app.ActivityThread.main(ActivityThread.java:4363)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at java.lang.reflect.Method.invoke(Method.java:521)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at dalvik.system.NativeStart.main(Native Method)
07-03 14:10:43.579: E/AndroidRuntime(249): Caused by: java.lang.reflect.InvocationTargetException
07-03 14:10:43.579: E/AndroidRuntime(249): 	at com.quiz.hero.QuizActivity.actionButtonPlay(QuizActivity.java:89)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at java.lang.reflect.Method.invoke(Method.java:521)
07-03 14:10:43.579: E/AndroidRuntime(249): 	at android.view.View$1.onClick(View.java:2026)
07-03 14:10:43.579: E/AndroidRuntime(249): 	... 21 more
07-03 14:10:43.579: E/AndroidRuntime(249): Caused by: java.lang.ArrayIndexOutOfBoundsException
07-03 14:10:43.579: E/AndroidRuntime(249): 	at com.quiz.hero.QuizActivity.play(QuizActivity.java:167)
07-03 14:10:43.579: E/AndroidRuntime(249): 	... 25 more
07-03 14:10:43.619: I/dalvikvm(249): threadid=7: reacting to signal 3
07-03 14:10:43.629: I/dalvikvm(249): Wrote stack trace to '/data/anr/traces.txt'
 
Zuletzt bearbeitet:
und der Logcat?
 
ich habe den Logcat nach dem Code für play() angehängt.
 
Ich geb dir einen Tip: der choice[] Index geht von 0 bis 3.
In den letzten 4 Zeilen kann dieser Wert überschritten werden.
 
dann war das -1 doch richtig?
 
Ja du füllst positions soweit ich das gesehen habe mit zahlen von 1 bis 4.
 
  • Danke
Reaktionen: MrYouMath
Also irgendwie rettet mich das -1 auch nicht. Wieder ein Fehler.

Code:
07-03 18:22:59.963: D/dalvikvm(223): GC freed 515 objects / 46968 bytes in 105ms
07-03 18:23:05.302: D/dalvikvm(223): GC freed 1787 objects / 96216 bytes in 66ms
07-03 18:23:05.402: D/AndroidRuntime(223): Shutting down VM
07-03 18:23:05.402: W/dalvikvm(223): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
07-03 18:23:05.402: E/AndroidRuntime(223): Uncaught handler: thread main exiting due to uncaught exception
07-03 18:23:05.443: E/AndroidRuntime(223): java.lang.IllegalStateException: Could not execute method of the activity
07-03 18:23:05.443: E/AndroidRuntime(223): 	at android.view.View$1.onClick(View.java:2031)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at android.view.View.performClick(View.java:2364)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at android.view.View.onTouchEvent(View.java:4179)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at android.widget.TextView.onTouchEvent(TextView.java:6541)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at android.view.View.dispatchTouchEvent(View.java:3709)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1659)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at android.app.Activity.dispatchTouchEvent(Activity.java:2061)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1643)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at android.os.Handler.dispatchMessage(Handler.java:99)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at android.os.Looper.loop(Looper.java:123)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at android.app.ActivityThread.main(ActivityThread.java:4363)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at java.lang.reflect.Method.invoke(Method.java:521)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at dalvik.system.NativeStart.main(Native Method)
07-03 18:23:05.443: E/AndroidRuntime(223): Caused by: java.lang.reflect.InvocationTargetException
07-03 18:23:05.443: E/AndroidRuntime(223): 	at com.quiz.hero.QuizActivity.actionButtonPlay(QuizActivity.java:89)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at java.lang.reflect.Method.invoke(Method.java:521)
07-03 18:23:05.443: E/AndroidRuntime(223): 	at android.view.View$1.onClick(View.java:2026)
07-03 18:23:05.443: E/AndroidRuntime(223): 	... 21 more
07-03 18:23:05.443: E/AndroidRuntime(223): Caused by: java.lang.ArrayIndexOutOfBoundsException
07-03 18:23:05.443: E/AndroidRuntime(223): 	at com.quiz.hero.QuizActivity.play(QuizActivity.java:166)
07-03 18:23:05.443: E/AndroidRuntime(223): 	... 25 more
07-03 18:23:05.482: I/dalvikvm(223): threadid=7: reacting to signal 3
07-03 18:23:05.502: I/dalvikvm(223): Wrote stack trace to '/data/anr/traces.txt'
 
Zuletzt bearbeitet:
Ich sehe du hast da noch eine zweite ArrayList die leer ist und mit set() gefüllt wird statt mit add(), die idValues
 
Da hast du recht, aber die idValues initialisiere ich doch mit
Code:
for (int i = 0 ; i < 4 ; i++){idValues.add(i+1);}

Danach lasse ich erst den do loop durchlaufen, um dann das Ganze mit .set richtig zu machen.

Ist das nicht richtig? Wie sollte ich es dann machen?
 
Die Zeile habe ich übersehen das ist OK.
Wie ist MAXID definiert ich hab jetzt die Vermutung, dass der hintere Teil der untersten 4 Zeilen nicht passt also das der Index bei setText(names[.....])
 

Ähnliche Themen

B
Antworten
0
Aufrufe
684
basementmedia
B
P
Antworten
6
Aufrufe
1.080
Phillip1996
P
Zurück
Oben Unten