【发布时间】:2012-10-13 17:18:48
【问题描述】:
我正在使用 setContent 创建一个带有自定义布局的通知,它工作正常。 但是,当我使用 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;
我试图找到某个地方来控制通知操作布局,但没有成功。有什么帮助吗?
【问题讨论】:
标签: android android-notifications android-4.2-jelly-bean