Android:从活动外部调整小部件的参数
我的应用程序从 TabActivity 开始,该 TabActivity 具有与其关联的三个活动,每个选项卡一个。
然后,我有一个单例类,它保存可以通过这些选项卡操作的所有值,主要使用 SeekBars。
但是,某些 SeekBar 需要能够调整其他 SeekBar 上的值,包括另一个选项卡/活动中的值。
当用户调整 SeekBar 时,我有侦听器来检测更改。在这里我更新了单例中的值。从那里我希望单例能够更新其他一些 SeekBar 上的参数。
通常(非 Android),我会获得对 UI 类的引用,以便能够访问 setter 方法,但我很难找到如何做到这一点,因为 Android 的做法似乎有点不同(意图?)。
有什么简单的方法可以实现这一点吗?
My app starts with a TabActivity that has three activities associated to it, one for each tab.
I then have a singleton class that holds all the values that can be manipulated via these tabs, predominately using SeekBars.
However, some of the SeekBars need to be able to adjust values on other SeekBars, including those in another tab/activity.
I have listeners to detect the changes when the user adjusts a SeekBar. In this I update the value in the singleton. From there I want the singleton to be able to update the parameters on some of the other SeekBars.
Normally (non-Android), I'd get references to the UI classes to be able to access setter methods but I'm having difficulty in finding out how to do this as Android appears to do things a little differently (intents?).
Is there any easy way to accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
卡 B 活动将恢复(调用 onResume)
当我们从选项卡 B 切换到选项卡 C 时,如果您更改选项卡 B 中静态变量的值并且切换到选项卡 B,则选项 。状态
覆盖 Resume 方法..将日志放在方法内并检查
when we switch from Tab B to C, Tab B activity is resumed (onResume called)
if you change the value of a static variable in tab B and the switches to tab B.. the change will be refelected when u chk it in the Resume state
Override on Resume method.. put a log iniside the method and check
尝试(为此,您需要
上下文对象
):并在
Activity
端使用reciever方法来接收意图。您可以使用
intent.setAction(string)
来提供其他信息。Try (for this You need the
context object
):And on the
Activity
side use reciever method to receive the intent.You can use
intent.setAction(string)
to provide additional information.