int to image to imageview
I have a custom digital clock widget, where I would like to use a custom font. I have gotten hold of a pice of code that helps me along, but I need help on how to use it. Here is the method:
public static RemoteViews buildUpdate(Context context)
{
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.main);
Bitmap myBitmap = Bitmap.createBitmap(100, 50, Bitmap.Config.ARGB_4444);
Canvas myCanvas = new Canvas(myBitmap);
Paint paint = new Paint();
Typeface clock = Typeface.createFromAsset(context.getAssets(),"Clockopia.ttf");
paint.setAntiAlias(true);
paint.setSubpixelText(true);
paint.setTypeface(clock);
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.WHITE);
paint.setTextSize(15);
myCanvas.drawText("Test", 0, 0, paint);
views.setImageViewBitmap(R.id.TimeView, myBitmap);
return views;
}
And here is my updateservice:
private void update() {
mCalendar.setTimeInMillis(System.currentTimeMillis());
final CharSequence time = DateFormat.format(mTimeFo开发者_高级运维rmat, mCalendar);
final CharSequence date = DateFormat.format(mDateFormat, mCalendar);
final CharSequence day = DateFormat.format(mDayFormat, mCalendar);
RemoteViews views = new RemoteViews(getPackageName(), R.layout.main);
views.setTextViewText(R.id.Day, day);
views.setTextViewText(R.id.Date, date);
buildUpdate(this);
ComponentName widget = new ComponentName(this, DigiClock.class);
AppWidgetManager manager = AppWidgetManager.getInstance(this);
manager.updateAppWidget(widget, views);
}
How will I get it to show the time using the buildUpdate method?
精彩评论