在log cat中初始化膨胀状态

时间:2012-07-04 10:27:46

标签: java android

这是一个Android小部件,我正在尝试为其添加自定义字体。

这是我的代码:

public void updateAppWidget(Context context,AppWidgetManager appWidgetManager,int appWidgetId)  
 {
    String currentTime = (String) df.format(new Date());

    RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.widget1);
    updateViews.setImageViewBitmap(R.id.widget1label, buildUpdate(currentTime, context));
    appWidgetManager.updateAppWidget(appWidgetId, updateViews);
 }

public Bitmap buildUpdate(String time, Context context) 
{
  Bitmap myBitmap = Bitmap.createBitmap(160, 84, Bitmap.Config.ARGB_4444);
  Canvas myCanvas = new Canvas(myBitmap);
  Paint paint = new Paint();
  Typeface clock = Typeface.createFromAsset(context.getAssets(),"batmfo.ttf");
  paint.setAntiAlias(true);
  paint.setSubpixelText(true);
  paint.setTypeface(clock);
  paint.setStyle(Paint.Style.FILL);
  paint.setColor(Color.WHITE);
  paint.setTextSize(65);
  paint.setTextAlign(Align.CENTER);
  myCanvas.drawText(time, 80, 60, paint);
  return myBitmap;
}  

buildUpdate()方法有什么问题吗? Eclipse在Logcat中没有显示错误。

0 个答案:

没有答案