我试图将此侦听器放在服务中,以在通知栏内的自定义视图中onClick
注册点击。但是得到编译器错误。有谁知道为什么会出现编译错误?button
xml
onClickListener
RemoteViews remoteviews = new RemoteViews("com.example.test", R.layout.custom_notifications);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(AudioService.this)
.setContent(remoteviews)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("My notification")
.setContentText("Hello World!")
.setOngoing(true);
remoteviews.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Toast.makeText(AudioViewer.this, "play button was clicked", Toast.LENGTH_LONG).show();
}
});
编译器的错误如下图所示: