Alexander Taran
Alexander Taran

Reputation: 1026

No method "getColor" in ColorDrawable in android

Eclipse gets me very strange error: The method getColor() is undefined for the type ColorDrawable

android.graphics.drawable.ColorDrawable dd = 
   new android.graphics.drawable.ColorDrawable();
dd.getColor();

I've no idea how to fix it. All other methods are exist. wtf?

Upvotes: 3

Views: 2032

Answers (2)

Lawrence D'Oliveiro
Lawrence D'Oliveiro

Reputation: 2794

Why not draw the Drawable into a tiny offscreen Bitmap, and call getPixel to retrieve the colour you drew?

Upvotes: 0

dwemthy
dwemthy

Reputation: 471

What is your target API level? ColorDrawable.getColor() is introduced in API level 11, so if you're targeting a lower API level you won't have access to that function.

Upvotes: 3

Related Questions