Note that there are some explanatory texts on larger screens.

plurals
  1. POStuck when call notifyDataSetChanged() method in android
    primarykey
    data
    text
    <p>This is my code to update ListView</p> <pre><code>public void onReceive(Conversation newConversation, Message message) { LogManager.getLogger(getClass()).info("onReceive"); Conversation conversation = null; ListConversationAdapter adapter = (ListConversationAdapter)listViewConversation.getAdapter(); int size = adapter.getCount(); LogManager.getLogger(getClass()).info("size: " + size); if(size &gt; 0) { for(int i=0;i&lt;size;i++) { if(adapter.getItemId(i) == newConversation.getId()) { conversation = (Conversation)adapter.getItem(i); break; } } } if(conversation == null) { adapter.addItem(newConversation); LogManager.getLogger(getClass()).info("add new conversation to adapter"); } LogManager.getLogger(getClass()).info("adapter.getCount(): " + adapter.getCount()); adapter.notifyDataSetChanged(); LogManager.getLogger(getClass()).info("notify dataset changed"); } } </code></pre> <p>This is output result after my method called</p> <pre><code>onReceive size: 0 add new conversation to adapter adapter.getCount(): 1 </code></pre> <p>it stop at line LogManager.getLogger(getClass()).info("adapter.getCount(): " + adapter.getCount()); and lock adapter.notifyDataSetChanged(); method forever what's wrong in my code? Help me please! This is getView method</p> <pre><code>public View getView(int position, View convertView, ViewGroup parent) { Conversation conversation = conversations.get(position); if(conversation != null) { LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout parentView = (LinearLayout) inflater.inflate(R.layout.conversation_item, null); TextView textViewName = (TextView)parentView.findViewById(R.id.textViewName); TextView textViewLastMessage = (TextView)parentView.findViewById(R.id.textViewLastMessage); textViewName.setText(conversation.getName()); List&lt;Message&gt; messages = MessageManager.getProvider().getMessages(conversation.getId(), 0, 0); if(messages.size() &gt; 0) { Message message = messages.get(messages.size() - 1); textViewLastMessage.setText(Emoticon.getSmiledText(message.getBody())); } LogManager.getLogger(getClass()).info("return not null view"); return parentView; } LogManager.getLogger(getClass()).info("return null view"); return null; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload