4
我正在使用setContent創建具有自定義佈局的通知,並且它工作正常。 但是當我使用addAction()向通知添加動作時,我的自定義佈局被忽略,它顯示了Android的默認通知佈局。將動作添加到jellybean中的通知中將忽略使用setContent設置的自定義佈局
當我收縮通知(使用兩個手指手勢)時,我的自定義佈局顯示,所以看起來「展開」窗體使用了我不能設置的不同佈局。
截圖(有了動作,然後經過刷卡兩根手指可縮小它)
正如你所看到的,它顯示了空(=默認佈局)時顯示的行動。
代碼:
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;
我想找個地方控制的通知與 - 行動的佈局,沒有運氣。任何幫助?