0

我有一个包含ArrayList<View>. 该课程对我有用,但我还无法保存(在本地归档)它。有没有可能呢?我尝试过SerializableExternalizable但总是得到一个NotSerializableException. 设置为瞬态也不起作用。那是代码(我知道Serializable不会工作):

public class ViewsData implements Serializable {

    private  ArrayList<View> viewsList = new ArrayList<View>();

    public ViewsData () {

    }


    public ArrayList<View> getViewsList() {
        return viewsList;
    }

    public void addToViewsList(View view) {     
        viewsList.add(view);        
    }
}

我非常感谢有关此的任何提示。

4

1 回答 1

0

I have done something quite like what you are trying to do and this was my way to solve it.

What I did was using a database to store all information. And a new class that created views of this information.

Everytime I started the application I had to recreate the ArrayList from the database strings. But this was very handy in my case.

When you add a View in the ArrayList, make sure you go thru the database and not just insert a View.

于 2013-10-19T13:48:29.527 回答