刷新通知栏进度条
我想在通知栏中放置一个进度条。这个想法是在程序将文件上传到服务器时显示进度条。其他一切都很好,但我不知道如何刷新通知内的进度条。有人知道有什么模式可以玩吗?我的意思是,我应该在服务或活动等中刷新进度条。
I would like to put a progress bar in the notification bar. The idea is showing the progress bar while the program uploads a file to a server. Everything else is ok, but I can not figure out how to refresh the progress bar inside the notification. Does anybody knows any pattern to play with? I mean, where I should refresh the progress bar, in a service or activity and so.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不知道你的代码是什么样的,所以我不知道你需要修改什么,但我做了一些搜索文档。我在通知、ProgressBar 和 RemoteViews。
具体来说,在RemoveView中,您可以更新进度栏。因此,结合每个链接中的一些示例代码,我得到如下内容:
I don't know what your code looks like, so I don't know what you need to modify, butI did some searching through the documentation. I found some stuff on Notifications, ProgressBars, and RemoteViews.
Specifically, in RemoveView, you can update the Progress bar. So combining some of the example code in each link, I get something like this:
您可以在通知中使用自定义视图:
https://developer.android.com/guide/topics/ ui/notifiers/notifications.html#CustomExpandedView
You can use custom views in Notification:
https://developer.android.com/guide/topics/ui/notifiers/notifications.html#CustomExpandedView
要从 RemoteView 中删除 ProgressBar,请使用以下代码:-
您也可以使用
View.GONE
但这将使 android 填充空白空间。To remove a ProgressBar from RemoteView use the following code :-
You can also use
View.GONE
but that will make android to fill empty space.