2011-03-02 48 views
0

在Honeycomb的豐富通知中設置可點擊按鈕的正確方法是什麼?像這裏顯示的媒體播放按鈕(這是我認爲是從音樂應用程序) -如何在蜂窩豐富通知中設置可點擊的按鈕?

http://androidcommunity.com/google-details-honeycombs-notification-bar-20110202/

這不是setSmallIcon()在Notification.Builder。該呼叫設置了標識狀態欄中的應用程序的圖標。

看看Notification.Builder,我們需要用RemoteViews對象調用setContent()嗎?

回答

4

正確您需要創建一個RemoteViews對象,它允許您通過調用setOnClickPendingIntent爲其中的各個小部件指定PendingIntent。然後,您可以設置此RemoteViewsNotificationcontentView

RemoteViews layout = new RemoteViews(getPackageName(), R.layout.notification); 
notification.contentView = layout; 
layout.setOnClickPendingIntent(R.id.notification_button, getDialogPendingIntent("Tapped the 'dialog' button in the notification.")); 

對於這一個完整的例子見Honeycomb Gallery