如何对小部件的多个实例使用一个首选项活动?
我正在开发一个 Android 主屏幕应用程序小部件。
我正在尝试向小部件添加首选项。我可以放置多个小部件。但我想使用动态创建的共享首选项来配置它。
我如何从资源文件中加载首选项,该文件从共享首选项中获取值并更新它?
有什么建议吗?
I am working on an android home screen app widget.
i am trying to add preferences to the widget. i can put multiple widgets. but i want to configure it with preferences using shared preference created dynamically.
how can i load the preference from the resource file which fetches the value from the sharedpreference and also updates it?
any suggestion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题的关键是如何使用 PreferenceActivity 保存的设置作为参考并创建自己的设置。下面是我使用单个 PreferenceActivity 实现的应用程序小部件的多个实例的多个设置。
The key to the problem is to somehow use the setting saved by PreferenceActivity as reference and create your own setting. Below is what I used to achieve having multiple setting for multiple instances of app widget with single PreferenceActivity.
也许尝试在文件系统上的某个地方编写您自己的偏好系统。
只是建议
maybe try to write your own preference system maybe on somewhere on filesys.
just suggesting