本文介绍了Android通知-自定义inboxstyle(添加行)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以类似gmail的样式创建一个可扩展的创建通知.通常,使用NotificationCompat.InboxStyle就足够了.但是我需要在每一行中添加一个图标.就像Whatsapp一样.看截图有什么想法如何实施吗?除了使用RemoteViews自定义布局

I'd like to create a create expandable notification, in the pretty much gmail-like style. In general, using NotificationCompat.InboxStyle would be enough. But i need to add an icon in each line. Pretty much like Whatsapp do.See the screenshotAny ideas how to implement it? Besides custom layout with RemoteViews

推荐答案

快速编写了一些较差的代码,到处都有表情符号.

Quickly wrote some poor code and I have emojis everywhere.

String emoji = new String(Character.toChars(0x1F60A));
Notification noti = new Notification.Builder(this)
            .setContentTitle("5 New mails from " + emoji)
            .setContentText(emoji)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setStyle(new Notification.InboxStyle()
                    .setBigContentTitle(emoji)
                    .addLine(emoji)
                    .addLine(emoji)
                    .setSummaryText(emoji))
            .build();

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, noti);

这篇关于Android通知-自定义inboxstyle(添加行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 01:27