我想在android的状态栏上将数字显示为文本。我已经设置了图标,但我想设置一个动态的数字。有可能做到这一点吗。
//Create the Notification
Notification notification = new Notification(android.R.drawable.stat_sys_warning, "Battery Indicator", System.currentTimeMillis());
//Create a PendingIntent to do something when the user clicks on the Notification
//Normally this would be something in your own app
Intent intent = new Intent();
intent.setClass(getApplicationContext(), BatteryIndicator.class);
PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0);
//Add the detail to the Notification
notification.setLatestEventInfo(getApplicationContext(),"Battery Indicator", "Charge level: " + batteryRemaining , pi);
//Display the Notification
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, notification); 发布于 2013-01-23 16:10:33
Android ProgressBar (如果你指的是这个类)不支持任何setText之类的东西。我建议创建一个覆盖onDraw(Canvas)的自定义组件。您可以调用super.onDraw来完成大部分工作,然后使用Canvas.drawText将数字绘制到中心位置(使用View.getWidth和getHeight查找中心位置)。
发布于 2013-01-23 16:58:23
使用notification.number=value;
https://stackoverflow.com/questions/14474866
复制相似问题