Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Using custom View in Widget

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?

like image 302
Patrick Avatar asked Aug 02 '10 13:08

Patrick


1 Answers

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

like image 64
Chris623 Avatar answered Nov 14 '22 20:11

Chris623