Apps Has Stopped,while Click The Item In An Listview In The Second Time
Solution 1:
I think that problem is that your are updating your Adapter
ouside of UI Thread and it caused your Exception.
I guess that you need to make sure that you are manipulating with UI elements only from UI Thread. And if you are using AsyncTask so you need to call
adapter.notifyDataSetChanged();
in onProgressUpdate()
or onPostExecute()
method
Solution 2:
The content of the adapter has changed but ListView did not receive a notification.
This issue means that the data that your basicAdapter is trying to adapt for the listView was changed, obviously means your itemDetailsrrayList
doesn't contain the same data.
I suppose that you are manipulating this list in your activities.
That's normal to happen, and what you should do, is to notify the adapter by calling adapter.notifyDataSetChanged()
in onResume callback of the activity using the adapter.
Solution 3:
This is the correct code i got ItemListAdapter.java
publicsynchronizedvoidrefreshAdapter(ArrayList<Recipedetails> items){
//itemDetailsrrayList.clear();
itemDetailsrrayList = items;
notifyDataSetChanged();
}
and in mylistviewactivity.java
privatevoidrefreshYourAdapter(final ArrayList<Recipedetails> items){
//this is what I meant. The error clearly states you are not updating the adapter on the UI thread runOnUiThread(new Runnable() { public void run() { _itemListAdapter.refreshAdapter(items); } }); } and
@Override
protected void onResume() { super.onResume(); _itemListAdapter = new ItemListBaseAdapter(this, image_details); refreshYourAdapter(GetSearchResults()); lv1.setAdapter(_itemListAdapter);
} we have to add these things in your listview activity it will works very fine and remove static in idemlistadapter
Post a Comment for "Apps Has Stopped,while Click The Item In An Listview In The Second Time"