Tecnologia do Blogger.
RSS

Re: [androidbrasil-dev] Re: java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification.

Rodrigo, sua resposta foi de extrema ajuda. Atualmente eu estou usando esse pattern de listener como vc indicou e está tudo funcionando muito bem, até então nenhuma resposta havia me funcionado tão bem. Eu adiciono e removo o listener no onResume() e onPause() do fragment, o que me facilita muito. Após adicionar uma mensagem (via UI thread), é só verificar se existe um listener na conversa (o que indica que ela está sendo exibida) e chamar o metodo de atualização nela.

public void addMessage(Mensagem mensagem, int limit)
throws CalledFromWrongThreadException {

if (Looper.getMainLooper().getThread() == Thread.currentThread()) {

log.add(mensagem);

verificaLimite(limit);

if (mListener != null) {
mListener.notifyListview();
}

} else {
throw new CalledFromWrongThreadException(
"Este método precisa ser chamado via UI Main Thread.");
}
}

Muito obrigado cara. Sem palavras.

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário