我在AndroidStudio 1.4.1中设置了一个通知,并且遇到了setStyle函数的错误。Android NotificationCompat.BigTextStyle错误
这是代码:
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this);
builder
.setSmallIcon(R.drawable.ic_assignment)
.setContentTitle("Easteregg found!");
String easter = "You found our Easteregg! Well done";
//custom colour
int color = getResources().getColor(R.color.primaryColor);
builder.setContentText(easter);
builder.setColor(color);
builder.setStyle(new NotificationCompat.BigTextStyle(easter));
Notification notification = builder.build();
NotificationManagerCompat.from(this).notify(0, notification);
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
// Vibration pattern
long[] pattern = {0, 100, 250, 320};
v.vibrate(pattern, -1);
当调用builder.setStyle(新NotificationCompat.BigTextStyle(复活节));我收到“BigTextStyle无法应用于java.lang.string”的通知
由于我使用Google提供的样本https://www.youtube.com/watch?v=-iog_fmm6mE,所以我非常困惑。我也尝试了一些基本的bug修复,但没有解决问题,所以我问你。
如果有人能帮助我,我会非常感谢。
在此先感谢。
P.S .:如果我遗漏了一些东西,请通知我有关它,我会尽我所能,并为您提供所有需要的信息。 *(无双关语意图)
是的,这工作,非常感谢你的回答,并与API文档的提示! 在这里,有一朵野花作为礼物。 http://wildflower.resn.co.nz/?CodeTillYouDrop+Tanisx –
哇,从来没有得到过其中之一,谢谢! –