Google Wear翻译文档6:给通知添加页面

Adding Pages to a Notification给通知添加页面

When you'd like to provide more information without requiring users to open your app on their handheld device, you can add one or more pages to the notification on Android Wear. The additional pages appear immediately to the right of the main notification card. For information about when to use and how to design multiple pages, see the Design Principles of Android Wear.

当你想提供更多的信息,而且不需要用户使用手持设备打开应用时,你可以在Android Wear上为通知添加一个或若干页面。附加的页面会在主通知卡片的右边立即显示出来。关于什么时候且如何设计多页面,请看 Design Principles of Android Wear

When creating a notification with multiple pages, start by creating the main notification (the first page) the way you'd like the notification to appear on a phone or tablet. Then, add pages one at a time with the addPage() method, or add multiple pages in a Collectionwith the addPages() method.

For example, here's some code that adds a second page to a notification:

当创建多条张页面时,把通知显示在手机或平板上是第一步,先创建一个主通知(第一张页面),然后,使用 addPage()方法每次添加一张页面,或者使用addPages()方法从 Collection对象添加若干页面。


// 为主通知创建 builder
NotificationCompat.Builder notificationBuilder =
       
new NotificationCompat.Builder(this)
       
.setSmallIcon(R.drawable.new_message)
       
.setContentTitle("Page 1")
       
.setContentText("Short message")
       
.setContentIntent(viewPendingIntent);

// 为第二张页面创建big text风格
BigTextStyle secondPageStyle = new NotificationCompat.BigTextStyle();
secondPageStyle
.setBigContentTitle("Page 2")
               
.bigText("A lot of text...");

// Create second page notification
Notification secondPageNotification =
       
new NotificationCompat.Builder(this)
       
.setStyle(secondPageStyle)
       
.build();

// Create main notification and add the second page
Notification twoPageNotification =
       
new WearableNotifications.Builder(notificationBuilder)
       
.addPage(secondPageNotification)
       
.build();
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值