1

I've home screen widget with ListView inside (Android 4.x - ICS), and after some change the listed items are not correctly displayed - I mean, the "old" data are displayed. Its always in this way:

  1. visible part of listview has ALWAYS good (= new) data displayed
  2. invisible part of list (scroll up or down) ALWAYS shows some of items old (and some not)

It looks, like the not visible part of list is cached, and when I scroll up or down, only few items are refreshed, and other not. And it looks funny, because when I'm scrolling up and down, some items are showing old, some new, and always different items, like absolutely randomly. It's simple strange...

What's the problem? Here is my ListView:

<ListView
    android:id="@+id/panelNews"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_marginLeft="@dimen/padding"
    android:layout_marginRight="@dimen/padding"
    android:layout_weight="1"
    android:gravity="top"
    android:paddingTop="@dimen/padding"
    android:scrollingCache="false"
    android:animationCache="false">
</ListView>

And here is code of my MyWidgetServiceFactory method (this method is fired on each data change):

public void onDataSetChanged() {
    MyLogger.log(TAG, "onDataSetChanged");
    listItems = dbHandler.getRecords(prefHandler);
}

And this is how I notify MyWidgetServiceFactory about data change from my UpdateService:

AppWidgetManager manager = AppWidgetManager.getInstance(this);
int[] appWidgetIds = manager.getAppWidgetIds(new ComponentName(this, MyWidget.class));
manager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.panelNews);
qkx
  • 2,061
  • 4
  • 22
  • 44

2 Answers2

0

You should use function

notifyDataSetChanged()

called on adapter you are using to populate your list. Check this link for more details.

Community
  • 1
  • 1
sinisha
  • 973
  • 11
  • 29
  • I'm notofying about data change - see updated question last few lines. PS: ListView on home screen don't have an Adapter, but RemoteViewsService and RemoteViewsServiceFactory. – qkx Aug 15 '12 at 09:35
0

ok, completely my fault, it was stupid mistake - I just forgot to update 1 field.

qkx
  • 2,061
  • 4
  • 22
  • 44