i made a 开发者_JAVA百科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?
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.
But you could use an ImageView which is supported in a widget:
- 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());
- Assign this bitmap to ImageView in the widget by using
remoteViews.setImageBitmap(viewID, mBitmap);
See this post for more information
精彩评论