特定于实例的 AppWidget 配置
假设有一个 App Widget,它在放置时显示配置 Activity 。配置页面允许调整小部件的外观。
用户可以在其主屏幕上放置此小部件的多个实例。在每个小部件实例上维护唯一配置状态的最佳方法是什么?或者每个小部件实例都必须采用相同的全局状态?
Say that there is an App Widget that shows a configuration Activity when placed. The configuration page allows adjusting the appearance of the widget.
The user may place multiple instances of this widget on their home screen. What would be the best way to maintain the unique configuration states on each of the widget instances? Or would each widget instance have to adopt the same global state?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道这是一篇旧文章,但是...
我是通过编写一个标识/命名为 widgetId 的文件来实现的。当手机重新启动时,widgetId 会被保留,并且我的小部件会读取该文件。每次我配置每个小部件时,它都会写入自己的文件,直到小部件从屏幕上删除并重新创建。
我听说最好使用 SQLlite 而不是文件,但我还没有研究过。
I know this is an old post, but...
I am doing it by writing a file identified/named as the widgetId. When the phone is rebooted the widgetId is maintained and my widget reads the file. Each time I configure each widget it writes to its own file until the widget is deleted from the screen and recreated.
I have heard that it is best to use SQLlite instead of files, but I have not looked into that yet.