Android, ListView IllegalStateException: “The content of the adapter has changed but ListView did not receive a notification”

What I want to do: run a background thread which calculates ListView contents and update ListView partially, while results are calculated. What I know I have to avoid: I cannot mess with ListAdapter contents from background thread, so I inherited AsyncTask and publish result (add entries to adapter) from onProgressUpdate. My Adapter uses ArrayList of … Read more

setState() or markNeedsBuild called during build

class MyHome extends StatefulWidget { @override State<StatefulWidget> createState() => new MyHomePage2(); } class MyHomePage2 extends State<MyHome> { List items = new List(); buildlist(String s) { setState(() { print(“entered buildlist” + s); List refresh = new List(); if (s == ‘button0’) { refresh = [ new Refreshments(“Watermelon”, 250), new Refreshments(“Orange”, 275), new Refreshments(“Pine”, 300), new Refreshments(“Papaya”, … Read more

How does setting baselineAligned to false improve performance in LinearLayout?

I was just building some UI in xml, and Lint gave me a warning and said to set android:baselineAligned to false to improve performance in ListView. The docs for the Lint changes that added this warning say Layout performance: Finds LinearLayouts with weights where you should set android:baselineAligned=”false” for better performance, and also finds cases … Read more

Should we use RecyclerView to replace ListView? [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 1 year ago. Improve this question Android Docs say: The RecyclerView widget is a more advanced and flexible version of ListView. This … Read more

OnItemCLickListener not working in listview

Activity class code: conversationList = (ListView)findViewById(android.R.id.list); ConversationArrayAdapter conversationArrayAdapter=new ConversationArrayAdapter(this, R.layout.conversation_list_item_format_left, conversationDetails); conversationList.setAdapter(conversationArrayAdapter); conversationList.setOnItemClickListener(new AdapterView.OnItemClickListener(){ @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { Log.d(“test”,”clicked”); } }); The getView function in the Adapter class: if (v == null) { LayoutInflater vi = (LayoutInflater)ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); if(leftSideMessageNumber.equals(m.getTo())) { v = vi.inflate(R.layout.conversation_list_item_format_left, null); } else { v … Read more