Autore Topic: StackOverflow Error durante la creazione di una lista  (Letto 676 volte)

Offline MikeKeepsOnShine

  • Utente junior
  • **
  • Post: 84
  • Respect: 0
    • mikekeepsonshine
    • Mostra profilo
  • Dispositivo Android:
    Samsung Galaxy Fame , Samsung Galaxy Tab 2 7.0
  • Sistema operativo:
    Windows 7
StackOverflow Error durante la creazione di una lista
« il: 08 Maggio 2013, 14:36:23 CEST »
0
Hi there.
Sto sviluppando un'app in cui è previsto una sezione 'carrello', in cui i prodotti selezionati vengono salvati e poi visualizzati.
Al momento della visualizzazione però, la lista dei prodotti con pulsante annesso fa crashare l'app.
questo è il codice che uso per creare una riga per singolo prodotto:
Codice (Java): [Seleziona]
while(i<tot_carrello){
                                LinearLayout prodotto = new LinearLayout(context);
                                //Nome prodotto
                                TextView nome_p = new TextView(context);
                                nome_p.setWidth(120);
                                nome_p.setTextColor(getResources().getColor(R.color.grey));
                                nome_p.setText(cns.getNomeProdotto());
                                //Quantita
                                TextView quantita = new TextView(context);
                                quantita.setWidth(80);
                                quantita.setTextColor(getResources().getColor(R.color.grey));
                                quantita.setText(cns.getQuantita());
                                //Prezzo
                                TextView prezzo = new TextView(context);
                                prezzo.setWidth(70);
                                prezzo.setTextColor(getResources().getColor(R.color.grey));
                                prezzo.setText(cns.getCosto());
                                //Cancella
                                Button canc = new Button(context);
                                canc.setBackground(getResources().getDrawable(R.drawable.btn_canc));
                                canc.setId(Integer.parseInt(cns.getIDprodotto()));
                                //Mostra
                                prodotto.addView(prodotto);
                                prodotto.addView(quantita);
                                prodotto.addView(prezzo);
                                prodotto.addView(canc);
                                scroll.addView(prodotto);
                                i++;
                }
tot_carrello è il numero di prodotti fino ad ora salvati.
Il logcat, al momento del crash:
Codice (Java): [Seleziona]
05-08 10:44:50.713: E/AndroidRuntime(1145): FATAL EXCEPTION: main
05-08 10:44:50.713: E/AndroidRuntime(1145): java.lang.StackOverflowError
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.View.isLayoutDirectionInherited(View.java:11749)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5396)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.view.ViewGroup.resetResolvedLayoutDirection(ViewGroup.java:5397)
05-08 10:44:50.713: E/AndroidRuntime(1145):     at android.vie

Come posso ovviare a questo problema? (anche perchè per ora tot_carrello=1, ed è già un dramma :-o).
Grazie!
True perfection has to be imperfect

Offline Sakazaki

  • Utente normale
  • ***
  • Post: 396
  • Respect: +74
    • Mostra profilo
  • Dispositivo Android:
    Sony xperia Z
  • Play Store ID:
    Saka Labs
  • Sistema operativo:
    Windows 8
Re:StackOverflow Error durante la creazione di una lista
« Risposta #1 il: 08 Maggio 2013, 15:01:00 CEST »
0
Perché quando "mostri" a prodotto aggiungi se stesso?

Offline MikeKeepsOnShine

  • Utente junior
  • **
  • Post: 84
  • Respect: 0
    • mikekeepsonshine
    • Mostra profilo
  • Dispositivo Android:
    Samsung Galaxy Fame , Samsung Galaxy Tab 2 7.0
  • Sistema operativo:
    Windows 7
Re:StackOverflow Error durante la creazione di una lista
« Risposta #2 il: 09 Maggio 2013, 10:45:30 CEST »
0
Perché quando "mostri" a prodotto aggiungi se stesso?

dah! è un residuo di un vecchio tentativo ... togliendolo funziona.
Grazie
True perfection has to be imperfect