但是当我使用addAction()向通知添加动作时,我的自定义布局被忽略,它显示了 android的默认通知布局.
当我缩小通知(使用双指手势)时,我的自定义布局显示,因此“扩展”表单似乎使用了我无法设置的不同布局.
截图(使用 *** 作,然后向上滑动两根手指以缩小它)
如您所见,当显示 *** 作时,它显示为空(=默认布局).
代码:
RemoteVIEws remoteVIEw = new RemoteVIEws(context.getPackagename(),R.layout.notification_status);Builder builder = new Notification.Builder(context);builder.setSmallicon(icon) .setTicker(tickerText) .setWhen(when) .setContent(remoteVIEw) .setongoing(true) .setContentIntent(contentIntent) .setPriority(Notification.PRIORITY_HIGH) .addAction(R.drawable.ic_remove,"Action 1",cancelPendingIntent) .addAction(R.drawable.ic_stat_notify_gray_official,"Action 2",cancelPendingIntent) .setContentIntent(contentIntent);Notification statusNotification = builder.build();return statusNotification;
我试图找到一个地方来控制通知行动布局,没有运气.有帮助吗?
解决方法 有完全相同的问题!而不是打电话builder.setContent(remoteVIEw)
这取代了正常的内容,你应该这样做:
Notification statusNotification = builder.build();statusNotification.bigContentVIEw = remoteVIEws;
这将把你的布局设置为bigContentVIEw,它在扩展后变得可见!
注意:执行此 *** 作将阻止您的 *** 作按钮显示.有关如何解决此问题,请参阅In Android (on JB),how can I add an action to a custom rich notification?
总结以上是内存溢出为你收集整理的android – 在jellybean中向通知添加 *** 作会忽略使用setContent设置的自定义布局全部内容,希望文章能够帮你解决android – 在jellybean中向通知添加 *** 作会忽略使用setContent设置的自定义布局所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)