Вопрос

Alternative Titel: ListFragment Content does not get drawn when resuming after background memory has been cleared.

You can try this and see the source here it is the ActionBarSherlock demo app version of the Google Demo app.

When you open the ListFragment and go to other (high memory using apps). The ActivityManager will kill the process "No longer want ..." If you go then back to the Activity through long holding Home Button, the List gets reloaded but then appears "No Applications".

I can't find any cause for this behavior, maybe I'm blind maybe it is a bug. I spent some time debugging, in my opinion the applications are load, but then something prevent them to be displayed.

In Line 469 I added some debug messages.

        Log.d("onLoadFinished", data.get(0).getLabel());

The label is logged correctly in the above described case, but the "No Applications" appears instead of the list.

Can somebody explain to me, why this happens and how to fix it?

Это было полезно?

Решение

The problem seems to be related to the SearchViewCompat in line 442.

Resuming the app when its memory has been released in the background triggers onQueryTextChange on an empty adapter with the filter null, when the loader then updates the adapter, the items still don't get displayed.

A workound would be to call

mAdapter.getFilter().filter(null);

after mAdapter.setData(data); in onLoadFinished.

This might be a bug in compatibility framework, i didn't test the native implementation.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top