10

i made a extended a View, overwrote the 3 View Contructors and tried to insert it on my xml of a widget.

The Exception is:

java.lang.ClassNotFoundException: com.mypackage.myView in loader dalvik.system.PathClassLoader@4001e710

is it possible to use custom views in Widgets?

Patrick
  • 151
  • 2
  • 4

2 Answers2

12

is it possible to use custom views in Widgets?

If by "Widgets" you mean "app widgets", then, no. You cannot use custom View classes in app widgets.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
2

But you could use an ImageView which is supported in a widget:

  1. Create a Bitmap and draw with a Canvas on it:
Bitmap mBitmap = Bitmap.createBitmap(mWidht, mHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(mBitmap);
canvas.drawText("test", 0, 30, new Paint());
  1. Assign this bitmap to ImageView in the widget by using
remoteViews.setImageBitmap(viewID, mBitmap);

See this post for more information

einUsername
  • 1,569
  • 2
  • 15
  • 26
Chris623
  • 2,464
  • 1
  • 22
  • 30