android - Dialog and displaying it in a TextView -


IÂ've had a dialog where I can select many things, in my example content for a pizza. I want to select / select more than one item but every time I run the app, I can select more than one but it only displays one. Here's my code, I was ignoring it once but my mistake could not be found. I hope you can help me. Thanks in advance;)

  Private Zero pizzaBelagDialog () {// Variablen Ultimate ArrayList & LT; Integer & gt; Arraybill = new arreelist & lt; Integer & gt; (); DialogBuilder = New AlertDialog.Builder (this); Last string [] strBelaege = {"Hühnchen", "Pepperoni", "Pilze", "Zwiebeln", "Speak", "Oliven", "Ananas", "Pommes", "SOA ?? e", "Meeresfrüchte"} ; // process strBelag = "\ n Belag: \ n"; DialogBuilder.setTitle ("WAhle deinen Belag aus"); dialogBuilder.setMultiChoiceItems (strBelaege, null, New DialogInterface.OnMultiChoiceClickListener () {@Override public void onClick (DialogInterface dialogue that integer, boolean isChecked) {if (isChecked) {arrayBelag.add (a);} else if (arrayBelag.contains (Joe)) {arrayBelag.remove (Integer.valueOf (Joe));}}}); DialogBuilderksetPositiveButton ( "OK", the new DialogInterface.OnClickListener () {@Override public void onClick (DialogInterface dialog, int which) {(int intLoop = 0 in; intLoop & LT; arrayBelag.size (for); intLoop ++ ) {strBelag = strBelaege [(int) arrayBelag .Get (intLoop)] ""; display () ;;} Toast.makeText .show () (getApplicationContext () ,, Toast.LENGTH_SHORT ". Belag ausgewählt wurde") }}); dialogBuilder.setNegativeButton ( "Cancel", new DialogInterface.OnClickListener () {@Override public void onClick (DialogInterface dialog, int which) {Toast.makeText (getApplicationContext (), "Belag nicht ausgewählt wurde.", Toast.LENGTH_SHORT ). Show ();}}); // Output AlertDialog Dialogue PizzaBelag = dialogBuilder.create (); DialogPizzaBelag.show (); } Text   

Syntac

In each loop you override your variable strBelag . You should use this:. strBelag + = Your code + "" This way you keep the value added to the previous loop and do not change it <. / html>

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -