Hello. I already asked such a question, but never received an answer, I ask again :) I'm trying to draw a line, a circle or a rectangle on the widget through the canvas, but nothing happens ....

UPD: solution found http://dajver.blogspot.com/2012/04/canvas-android.html

  • @dajver, it is advisable not to duplicate questions. In the last topic you were given exactly the same, by the way, absolutely correct answer. - angry
  • I understand, but I did not understand how to bring all this to the widget ... I asked this question. - dajver
  • Judging by the blog entries, you have not accurately formulated this question. - angry

1 answer 1

And where does AppWidgetProvider? AppWidgetProvider is something similar to BroadcastReceiver - in fact, a certain service that says "I can show a widget," but he does not draw a widget! This is a provider!

To draw a widget, you need to create a custom class that inherits from View and in its onDraw() method write what you want. You already last time comrades pointed to your mistake.

Eslicho see an example implementation of a custom widget here.

Update

 public class MySuperPuperWidgetView extends SomeExistingWidgetView { @Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); //рисуем виджет //далее пишем свою хрень на канвасе } } 
  • Well, I'm trying to draw on it. Although I could be wrong, what are the suggestions? - dajver
  • one
    See the answer update - Barmaley
  • Thank you, I realized that I need to do this, but how can I display it later on the widget? This is what I do not understand. - dajver
  • one
    In the sense of a non-existent widget? We need to take the widget class, inherit from it, reboot its onDraw method, call super.onDraw () - so that it draws itself, and then draw on top what you want. - Barmaley
  • one
    See update in response - Barmaley