改变preference(设置)之后,文本显示设置不更新 [英] After changing a preference (a setting), text showing settings doesn't update

查看:229
本文介绍了改变preference(设置)之后,文本显示设置不更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我会尽量解释一个简单的应用场景:我的应用程序顺利,到主视图。在这个主视图我已经插入了一个的TextView 这显示了 preferenceManager 的方式建立的当前设置。为了简单起见,假设我有我的设置框。当我第一次开始我的应用程序 - 的的TextView 在我的主视图显示了我的复选框,设置正确(真)。现在我去设置菜单,它会弹出式,然后我将其更改为错误的。我回到主视图,看到没有变化。它仍然说是真的,即使我把它改成错误的。如果我最终的应用程序,然后重新启动 - 一切都很好,这显示了我的变化

I will try to explain a simple app scenario: My app goes right to a 'main view'. In this main view I have inserted a TextView which displays current settings created by way of the PreferenceManager. For simplicity sake, let's say I have a checkbox in my settings. When I first start my app - the TextView on my main view shows my checkbox setting correctly (true). Now I go to the settings menu, it pops-up, and then I change it to false. I go back to the main view and see no change. It still say's true even after I changed it to false. If I end the app and then re-start it - all is well and it shows my change.

显然,主视图只是停留在后台,而我改变设置?我如何重绘或更新主视图后,我更改设置?

Apparently the main view just stays in the background while I'm changing settings? How can I redraw or update the main view after I change settings?

推荐答案

当你进入你的preferences您当前的活动应该暂停,当你回去(见的 http://developer.android.com/guide/topics/fundamentals.html#lcycles">lifecycle图)。您应该能够引发某种重绘从内部onResume(),我觉得。这将允许在页上的数据来重新填充。某种无效的()调用会做我猜。

When you go into your preferences your current activity should be paused and the resumed when you go back (see the lifecycle diagram on lifecycle diagram on the android site). You should be able to trigger some kind of redraw from within onResume() I would think. That will allow the data on the page to repopulate. Some sort of invalidate() call would do it I guess.

这篇关于改变preference(设置)之后,文本显示设置不更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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