一種能夠顯示即時信息的控件,該控件顯示在標題欄中,拉開後會看到通知的完整樣式佈局
可選項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);