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. Creating Proxy Server

Looking for help with creating an http proxy server via Android. It's
a bit difficult to ask this question with examples, etc, because
networking isn't familiar to me, which means I don't quite know how to
get started, so I'll try to explain: I'm attempting to play an audio
stream using Android's MediaPlayer. It's a snap using setDataSource
and my URL string... only some phones (those still running Android
1.5) won't play the stream. Through research I've discovered that the
problem may reside with the headers associated with my stream URL,
that something in them is either missing, wrong, or simply needs to be
changed in order for the MediaPlayer not to reject the URL on
prepare() (could be length and/or content-type). I've been told that I
should attempt to solve the problem by creating an http proxy server
in my app, one where I can alter the headers to however I need them,
and then attach to the stream through this new proxy... but I haven't
the slightest idea on how to do this. Anyone have advice? I'd greatly
appreciate a point in the right direction through code, not just
suggestions like "look up HttpClient in the SDK", because I've been
through all of that and am getting nowhere. Thanks...

-- 

2. Is it possible to turn on and off views?

I am trying to make a loading screen, that is generally seen in almost
any app nowadays. I can't find any examples on making something like
having a nice loading screen and then moving onto the actual
functional part of the app.

-- 

3. Writing text on icon of Menu in Android?

4. Trying to achieve scale centerCrop with Activity windowBackground drawabl

5. Mod: Hari dan Aturan Jual Beli di ID-Android

6. Unable to edit the SyncAdapter Contacts

7. Paging: akhmad hidayat (a...@isatdroid.com)