Extending Drawable Class

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


Sponsored Links
 Hello,

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
(R.drawable.testSprite);

How would I go about making this work?

Thanks.

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Work with Cursors

Hi,

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

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[]{
(...)
                                "day",
                                "month",
                                "year"}, null, null, null, null, null);
        }

And to populate a ListActivity, I use this method :

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

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
conditions.
Any useful link or tutorial. Thanks in advance.

Regards,
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