1. Download our Official Android App: Forums for Android!

Apps Implementing Drawable draw() method?

Discussion in 'Android Development' started by cmh0114, Jul 20, 2010.

  1. cmh0114

    cmh0114 Well-Known Member
    Thread Starter
    Rank:
    None
    Points:
    36
    Posts:
    114
    Joined:
    Jan 10, 2010

    Jan 10, 2010
    114
    7
    36
    I'm trying to create an object that will extend the class Drawable. However, I have no clue how to implement the draw() method, but if I don't implement it, nothing gets drawn. What code should I put within the draw() method so that my Drawable is drawn?
     

    Advertisement

  2. couch

    couch Lurker
    Rank:
    None
    Points:
    5
    Posts:
    6
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    6
    0
    5
    An obvious suggestion but
    ...
    super.draw();

    might work.
     
  3. cmh0114

    cmh0114 Well-Known Member
    Thread Starter
    Rank:
    None
    Points:
    36
    Posts:
    114
    Joined:
    Jan 10, 2010

    Jan 10, 2010
    114
    7
    36
    lol, thanks, but I already tried that.
    Drawable is an abstract class, and Drawable.draw() is an abstract method, so I have to write the code for it explicitly. :p
     
  4. cp1

    cp1 Android Enthusiast
    Rank:
    None
    Points:
    53
    Posts:
    375
    Joined:
    Apr 30, 2010

    Apr 30, 2010
    375
    35
    53
    Are you drawing using canvas?
     
  5. cmh0114

    cmh0114 Well-Known Member
    Thread Starter
    Rank:
    None
    Points:
    36
    Posts:
    114
    Joined:
    Jan 10, 2010

    Jan 10, 2010
    114
    7
    36
    I think so - a Canvas object is automatically passed in as a parameter to the draw() method.
     
  6. cp1

    cp1 Android Enthusiast
    Rank:
    None
    Points:
    53
    Posts:
    375
    Joined:
    Apr 30, 2010

    Apr 30, 2010
    375
    35
    53
    What are you trying to draw? A picture from a file, or a few lines?
     
  7. jonbonazza

    jonbonazza Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,930
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    1,930
    457
    163
    Male
    Can you post your code so we can see what we are working with?
     

Share This Page

Loading...