Android的 - 动态改变布局中保存状态 [英] Android - Saving state of dynamically changed layout

查看:103
本文介绍了Android的 - 动态改变布局中保存状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个布局,用户可以添加按钮,并将其放置在那里他们想要的。
我想允许用户使其加载它们打开应用程序下一次挽救他们的布局。
有谁知道,如果我能救上SD卡的文件?我也可以使用某种layout.getXml()方法,并把它放在我的应用程序使用的数据库。
在此先感谢

I have a layout where users can add buttons and place them where they want. I want to allow the user to save their layout so that it is loaded the next time they open the app. Does anyone know if I can save the file on the sdcard? Alternatively I could use some kind of layout.getXml() method and put it in the database my app uses. Thanks in advance

推荐答案

如果我是你,我会创建一个类都抱着这个布局和按钮的信息。而类的每个信息写与JSONWriter文件。当应用打开我只是用一个JSONObjects读取文件并重新创建阵列。

If I were you, I would create a class holding all the information about this layout and buttons. And write every information of the class to a file with JSONWriter. When the app has opened I just read the file and recreate the arrays using JSONObjects.

这篇关于Android的 - 动态改变布局中保存状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆