Extending Drawable Class

by cnatale37 » Tue, 26 May 2009 08:09:57 GMT

Sponsored Links

I'm fairly new to Android development, and having a couple of
questions concerning extending the Drawable class. I see that the draw
method has an abstract modifier. However, while looking at the Lunar
Lander example code, I noticed that several of the images being drawn
to the screen are of the Drawable type. How is this possible, since
the draw method is abstract?

Also, I tried extending the Drawable class into a Sprite class to
handle some additional properties and methods I need for a video game,
but I get a runtime ClassCastException error whenever I try to get a
Drawable resource from my Resources and cast it as a Sprite, like so:

private Sprite mSpriteImage;
mSpriteImage = (Sprite) context.getResources().getDrawable

How would I go about making this work?



Other Threads

1. Work with Cursors


I'm currently developing a small application for Android using a

I have a table with 3 fields : day, month, year.

When I retrieve them from the database, I use the following method :

public Cursor getAllItems(){
                return db.query(this.tableName, new String[]{
                                "year"}, null, null, null, null, null);

And to populate a ListActivity, I use this method :

public void bindData(){
        Cursor c = db.getAllItems();
        SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
                        new String[]{ (...) "day", "month", "year"},
                        new int[]{ (...) , R.id.TextDay, R.id.TextMonth, 

And it works.

Now, I would like to get those 3 fields and convert it into a specific
Object I have written (let's call it MyDate ^^)

How can I convert those 3 fields into one single string with my MyDate
object ? (using toString());

I don't know if I'm very clear... :s

Thanks for your help


2. How to Implement Ticker Component.

Hi all,

   I want to make Ticker Component but i dont know how to do this.
I have seen "Marquee" but it start scroll on focus but i dont want.
I want to scroll text if it is focused or not means in both
Any useful link or tutorial. Thanks in advance.

Gulfam Hassan


3. Sepi gini ini milis.. Share sesuatu deh.. :P

4. Why activity Icon is not removed from launcher

5. get device manufacturer or USB device id...

6. Problem with playing rtsp link using video view

7. How to create and acquire a Wifi Lock in WIFI_MODE_SCAN_ONLY mode