下面的代码,可以让你的程序变化图标
Bitmap icon=Bitmap.getBitmapResource("icon/unread.gif");
net.rim.blackberry.api.homescreen.HomeScreen.updateIcon(icon,1);
但是这还不够酷,能在图标上面加数字呢?数字用来指示有几个待办, 或者是气温多少?
把上面的代码改良一下:
Bitmap icon=Bitmap.getBitmapResource("icon/unread.gif");
Bitmap icon1 = getUpdateIconBitmap(icon, count);
net.rim.blackberry.api.homescreen.HomeScreen.updateIcon(icon1,1);
private Bitmap getUpdateIconBitmap(Bitmap bmp, int count) {
int width = bmp.getWidth();
int height = bmp.getHeight();
Bitmap iconBmp = new Bitmap(width, height);
Graphics g = new Graphics(iconBmp);
XYRect rect = new XYRect(0, 0, width, height);
g.drawBitmap(rect, bmp, 0, 0);
g.setFont(g.getFont().derive(Font.BOLD, 20, Ui.UNITS_px,
Font.ANTIALIAS_STANDARD, Font.COLORED_OUTLINE_EFFECT));
String text = Integer.toString(count);
g.setColor(Color.RED);
g.drawText(text, 0, 0);
return iconBmp;
}