Android Studio 进度条的视觉问题
我添加了一个选项,可以在活动编号 1 中单击它,以保存共享首选项,并且它应该重新启动活动 nr 2 中的进度条进度,但问题是,即使我转到活动 nr 2 并调用 setProgress(0) 并且 getProgress 返回0,进度条上的进度仍然存在,并且只有在重新启动应用程序后进度条才会更新。我应该做什么来修复它?
在活动 nr 1 中单击的代码
sharedPreferences.edit().putBoolean("restarted", true).apply();
在活动 nr 2 中设置进度条的代码
if(sharedPreferences.getBoolean("restarted", false)) {
progress.setProgress(0);
sharedPreferences.edit().putBoolean("restarted", false).apply();
}
I added an option to click on it in activity number 1 that saves sharedpreferences, and it should restart progressbar progress in activity nr 2, but the problem is that even when I go to activity nr 2 and setProgress(0) is called and getProgress returns 0, progress on progressbar is still there, and only after restarting app progressbar updates. What should I do to repair it?
Code on click in activity nr 1
sharedPreferences.edit().putBoolean("restarted", true).apply();
Code in activity nr 2 to set progressbar
if(sharedPreferences.getBoolean("restarted", false)) {
progress.setProgress(0);
sharedPreferences.edit().putBoolean("restarted", false).apply();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论