[英]In Android (on JB), how can I add an action to a custom rich notification?
I've been playing with the new rich notificaitons in Jelly Bean, and everything works as expected when I set up a new notificaiton using the templates Notification.BigPictureStyle
, Notification.BigTextStyle
, or Notification.InboxStyle
. 我一直在使用Jelly Bean中新的丰富的通知,当我使用模板
Notification.BigPictureStyle
, Notification.BigTextStyle
或Notification.InboxStyle
设置新的通知时,一切都按预期工作。 I can use the Notification.Builder.addAction()
method, and the action buttons show up at the bottom of the extended notification. 我可以使用
Notification.Builder.addAction()
方法,操作按钮显示在扩展通知的底部。 But when I try to create a cutsom notification using Notification.bigContentView , the action buttons never show up. 但是当我尝试使用Notification.bigContentView创建一个cutom通知时,操作按钮永远不会显示。
Just to clarify, if I never set bigContentView
, the buttons do show up. 只是为了澄清,如果我从未设置
bigContentView
,那么按钮就会显示出来。 But as soon as that field is set to a custom RemoteViews object, the buttons are gone. 但是只要该字段设置为自定义RemoteViews对象,按钮就会消失。
Does anyone have any ideas on why this is happening? 有没有人对为什么会这样做有任何想法?
The various Big...Style
builders create their own bigContentView
. 各种
Big...Style
构建器创建自己的bigContentView
。 If you want your own bigContentView
, you have to add the buttons yourself, perhaps by examining the source code to those builders and seeing how they do it. 如果你想要自己的
bigContentView
,你必须自己添加按钮,可能是通过检查这些构建器的源代码并了解它们是如何做到的。
When you add your custom bigContentView it will replace the contentview that is created by Notification.BigPictureStyle, Notification.BigTextStyle or Notification.InboxStyle. 当您添加自定义bigContentView时,它将替换由Notification.BigPictureStyle,Notification.BigTextStyle或Notification.InboxStyle创建的内容视图。 As commonsware point out you need to add the button by yourself and thats by creating your own custom remoteView with buttons and then add it as contentView.
正如commonsware所指出的那样,你需要自己添加按钮,然后通过按钮创建自己的自定义remoteView ,然后将其添加为contentView。
You could find a tutorial of how to do this here . 您可以在这里找到如何执行此操作的教程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.