List View Is Not Refreshing Even After Calling Notifydatasetchanged()
Solution 1:
As i have said in comment you messed with reference.See the code below:
privatevoidupdateResults(List<DeliveryListBean> dlb) {
deliveryListBeans=dlb;
notifyDataSetChanged();
}
Here you are assigning new list to the previous list so reference is changed . The adapter will never get notified cause adapter having previous reference . So the Solution is in two cases: if you want the old data too do as and second if you need only new data:
private void updateResults(List<DeliveryListBean> dlb) {
deliveryListBeans.addAll(dlb);
notifyDataSetChanged();
}
private void updateResults(List<DeliveryListBean> dlb) {
deliveryListBeans.clear();
deliveryListBeans.addAll(dlb);
notifyDataSetChanged();
}
Solution 2:
Why you create new Adapter??
DeliveryListAdapter ald=newDeliveryListAdapter(ct,deliveryListBeans);
I think you should just update for deliveryListBeans
and use this method of ADM user.
private void updateResults(List<DeliveryListBean> dlb) {
deliveryListBeans.clear();
deliveryListBeans.addAll(dlb);
notifyDataSetChanged();
}
I dont' see you use 'response' . You just check status from this var <- It is data from your server
Solution 3:
I found an alternative way of doing it. I just removed the
position
fromlist
and the mistake is creating new objectald=new DeliveryListAdapter(ct,deliveryListBeans);
you don't have to create any new object. What I did is
if (status==1)
{
Log.d("updated delivery",response.toString());
deliveryListBeans.remove(position);
notifyDataSetChanged();
Toast.makeText(ct, "Delivery Successful", Toast.LENGTH_SHORT).show();
}
Post a Comment for "List View Is Not Refreshing Even After Calling Notifydatasetchanged()"