1

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); 
4

2 に答える 2

0

Android ProgressBar (if you mean this class) does not support any setText or the like. I would propose to create a custom component overriding onDraw(Canvas). You can call super.onDraw to do the most of the work and then use Canvas.drawText to draw the number over in the center (use View.getWidth and getHeight to find where this center is).

于 2013-01-23T08:10:33.297 に答える
0

notification.number=value; を使用します。

于 2013-01-23T08:58:22.517 に答える