Android 是否将自定义扩展视图的事件添加到状态栏通知?
通过此链接,我可以将视图添加到状态栏。 . 但是如何为它定义事件。 假设我添加了两个按钮,那么如何为按钮设置onclick事件 这是我的远程查看代码Android 是否将自定义扩展视图的事件添加到状态栏通知?,android,Android,通过此链接,我可以将视图添加到状态栏。 . 但是如何为它定义事件。 假设我添加了两个按钮,那么如何为按钮设置onclick事件 这是我的远程查看代码 RemoteViews contentView=new RemoteViews(getPackageName(),R.layout.demo); notification.contentView = contentView; notification.flags |= Notification.FLAG_NO_CL
RemoteViews contentView=new RemoteViews(getPackageName(),R.layout.demo);
notification.contentView = contentView;
notification.flags |= Notification.FLAG_NO_CLEAR;
notification.flags |= Notification.FLAG_ONGOING_EVENT;
Intent intent = new Intent(getApplicationContext(), Main.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
intent, Intent.FLAG_ACTIVITY_NEW_TASK);
notification.contentIntent=contentIntent;
nm.notify(NOTIFY_ID, notification);
这里是R.layout.demo按钮。我如何定义事件?请详细说明。
thankx在您的
RemoteView
上,调用setOnClickPendingEvent()
,提供一个PendingEvent
,单击该按钮时将调用该按钮