Android-dev.it Community

 
Annunci

:arrow: Benvenuto!, se non sei ancora un utente registrato: puoi registrati qui, oppure effettua il login
:arrow: Apri un forum sul tuo nuovo smartphone Android e collabora con noi! (dettagli)

www.agendadigitale.org
Image


Sponsor
It is currently Thu May 24, 2012 8:29 am

All times are UTC + 1 hour


 Topics   Replies   Views   Last post 
No new posts Applicazione per gestire SMS

by filippo729 on Wed May 23, 2012 9:39 pm in Sviluppo e programmazione in Android

0

18

Wed May 23, 2012 9:39 pm

filippo729

No new posts На интернет-витрине

by popowahgjfghjoiuyt on Sat May 19, 2012 2:25 pm in Amministrazione

0

17

Sat May 19, 2012 2:25 pm

popowahgjfghjoiuyt

No new posts Apri un forum sul tuo nuovo smartphone Android!

[ Go to page: 1, 2, 3 ]

by ReattileGar on Fri May 18, 2012 5:27 pm in Amministrazione

27

12556

Fri May 18, 2012 5:27 pm

ReattileGar

No new posts Новый: базы для хрумера - профессиональный софт для СЕО.

by Renatafe on Fri May 18, 2012 3:14 pm in Amministrazione

0

27

Fri May 18, 2012 3:14 pm

Renatafe

No new posts Pace is undoubtedly the vital affordable Jerseys Wholesale d

by barnettmmolive2012 on Wed May 16, 2012 7:36 am in Amministrazione

1

49

Wed May 16, 2012 7:36 am

barnettmmolive2012




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Problema con ListView (probabile baco di Android ??)
PostPosted: Tue May 17, 2011 10:09 am 
Offline
User avatar

Joined: Tue May 17, 2011 9:42 am
Posts: 1
Punti Android: ?
Salve a tutti, sono nuovo di questo forum e questo è il mio primo topic.

Vi espongo subito il problema.

Sto sviluppando una app (API level 8, Target Android 2.2), la quale deve visualizzare una lista di risultati.

Per questo ho creato una classe che estende una ListActivity, che dovrà visualizzare degli oggetti custom. Gli oggetti custom vengono mappati in una classe creata ex-novo che estende la classe ArrayAdapter e che successivamente viene passata all'actitvity mediante il metodo setListAdapter(arrayAdapter);

Fin qui tutto ok, non ci sono stati problemi, funziona tutto alla perfezione. I problemi sono sorti nel momento in cui è nata l'esigenza di distinguere i vari item della ListView
in base ad un particolare stato definito da una proprietà (boolean) dell'oggetto custom che viene visualizzato. Ho pensato di evidenziare questo stato colorando con un colore diverso la riga dell'item, effettuando questo controllo nel metodo getView del mio adapter e settando dinamicamente il colore della riga in base alla proprietà.

Funziona ma fino ad un certo punto, nel senso che è tutto regolare fino a che non incontra il primo item che presenta la riga di colore diverso, ma da quel momento in poi scorrendo la lista degli item in maniere casuale MAGICAMENTE si iniziano a evidenziare anche altre righe che non dovrebbero evidenziarsi.
Code:
@Override
   public View getView(int position, View convertView, ViewGroup parent) {

      TextView cron, dest, ind, res, notificato;
      View v = convertView;
      if (v == null) {
         LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
               Context.LAYOUT_INFLATER_SERVICE);
         v = vi.inflate(R.layout.lista_atti_item, null);
      }

      final Atto atto = items.get(position);
      
      LinearLayout itemLayout = (LinearLayout) v.findViewById(R.id.item);
      notificato = (TextView) v.findViewById(R.id.notificato);
      cron = (TextView) v.findViewById(R.id.cronologico);
      dest = (TextView) v.findViewById(R.id.destinatario);
      ind = (TextView) v.findViewById(R.id.indirizzo);
      res = (TextView) v.findViewById(R.id.residenza);

      if ( atto.isModificato() )
      {
         Log.i(TAG_LOG, "L'atto " + atto.getDestinatario() + " ha l'esito settato!!");
         itemLayout.setBackgroundResource(R.color.celeste);
      }         
      
      itemLayout.setOnClickListener(new View.OnClickListener() {

         @Override
         public void onClick(View v)
         {
            Intent action = new Intent(getContext(),
                  AttoDetailActivity.class);

            Bundle bb = action.getExtras();
            if (bb == null)
               bb = new Bundle();

            bb.putSerializable("atto", atto);
            action.putExtras(bb);

            getContext().startActivity(action);

         }
      });

      if (atto != null)
      {
         cron.setText(atto.getCronologico());
         dest.setText(atto.getDestinatario());
         ind.setText(atto.getIndirizzo());
         res.setText(atto.getResidenza());
      }

      return v;
   }



Qualcuno sa spiegarmi che succede? :bang:
E' un baco oppure mi sfugge qualcosa?

Ovviamente prima di scrivere in questo forum ci tengo a precisare che sono andato anche in debug e vi assicuro che è tutto lineare.


Top
 Profile  
 
 Post subject: Re: Problema con ListView (probabile baco di Android ??)
PostPosted: Mon Jun 20, 2011 2:29 pm 
Offline
Moderatore
User avatar

Joined: Thu Dec 27, 2007 3:51 pm
Posts: 986
Cellulare Android: HTC Dream
Operatore: TIM
Punti Android: 1320
Ciao,
vedi se le informazioni che trovi qui possono esserti di aiuto: ***URLs are hidden from guests, please register and login to view the hyperlink***


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

Topic Tags

ListView ListActivity problema


All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
SitemapIndex SitemapIndex RSS Feed RSS Feed Channel list Channel list
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
phpBB SEO

All trademarks and logos used in this site are of properties of their respective owners.