Java tutorial
//package com.java2s; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Typeface; public class Main { public static Bitmap int2Icon(Context context, int i) { Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), 0x7f020047); Bitmap bitmap1 = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), android.graphics.Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap1); Paint paint = new Paint(); paint.setDither(true); paint.setFilterBitmap(true); canvas.drawBitmap(bitmap, 0.0F, 0.0F, paint); bitmap.recycle(); Paint paint1 = new Paint(257); paint1.setColor(-1); paint1.setTypeface(Typeface.DEFAULT_BOLD); paint1.setTextAlign(android.graphics.Paint.Align.CENTER); canvas.drawText(String.valueOf(i), bitmap.getWidth() / 2, 3 + bitmap.getHeight() / 2, paint1); return bitmap1; } }