一种能够显示即时信息的控件,该控件显示在标题栏中,拉开后会看到通知的完整样式布局
可选项ui
建立通知的步骤this
发布通知
NotifacationManager.notify(id,Notification)线程
点击事件code
象放入该对象中xml
代码以下对象
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.notification_icon) .setContentTitle("Event tracker") .setContentText("Events received") NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle(); String[] events = new String[6]; // Sets a title for the Inbox style big view inboxStyle.SetBigContentTitle("Event tracker details:"); ... // Moves events into the big view for (int i=0; i < events.length; i++) { inboxStyle.addLine(events[i]); } // Moves the big view style object into the notification object. mBuilder.setStyle(inBoxStyle);
mBuilder.setProgress(100,incr,false); mNotifyManager.notify(0,mBuilder.build());
建立一个RemoteViews对象,将xml布局加载到对象中,代码以下事件
RemoteView content =new RemoteViews(getPackageName(),R.layout.item);