E
E
egotyner2016-05-13 14:29:55
Java
egotyner, 2016-05-13 14:29:55

How to save data of Android ListView?

Предположим есть 2 фрагмента, один с ListView, а другой с кнопкой. Но другой не важен. Речь не о нём. Между фрагментами переключаюсь из навигационного меню (то что сбоку выезжает). При onCreate первого фрагмента он запускает задачу, которая заполняет ListView. (важно, используется кастомный адаптер наследованный от BaseAdapter). Так вот, процесс заполнения ListView весьма продолжительный, и что бы каждый раз не ждать, пока оно снова заполнит ListView при переключении между фрагментами, полагаю нужно этот ListView как-то сохранить. Пните пожалуйста в нужную сторону.
PS I tried to do it through parcel, but something didn’t work out very well, because my classes do not consist of base a la int, string, byte, but of instances of other classes and instances of base classes like File or something like that. And it seemed to me that it’s not so easy to shove the whole thing into parcel, besides, I didn’t quite understand the onSaveInstanceState (Bundle outState) and onCreate (Bundle savedInstanceState) methods. For example, what and where is passed to the onCreate method argument? By default, it is always null there, so you need to shove something there with your hands, but where and how? After all, you cannot directly call this method, and duplication of the call will work. But the onSaveInstanceState(Bundle outState) method is not called at all. Should it be called by hand? And what to pass to it as an argument? I do not quite understand the logic of interaction and data transfer. Help...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg Gamega, 2016-05-13
@egotyner

In your case, I would store everything in the base activity and drive the data using the eventbus
BUT .... there is a suspicion that you didn’t seriously take something into account when designing, are you sure that all this data is needed for the listview to work? File and Bitmap are perfectly replaced by a budget string, with a path, and so on ... in most cases, when heavy data is shoved into the ListView, they do it in vain
. Where does the ListView fill from? long filling is not good, maybe it can be somehow optimized and loaded in parts?
PS it is not necessary that this is the case for your application, but with a similar problem, such a question is worth asking yourself

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question