hi,
I wrote my own type of button. I want to pass values from main.xml
(the layout) to the class.
First I've got my attrs.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="OnOffButton">
<attr name="iBitmap" format="reference" />
<attr name="iMovementRate" format="integer" />
</declare-styleable>
</resources>
Reading the int iMovementRate is quite simple:
TypedArray ta = context.obtainStyledAttributes(attrs,
R.styleable.OnOffButton);
int iMovementRate =
ta.getInteger(R.styleable.OnOffButton_iMovementRate, 55);
Reading the Bitmap iBitmap drives me insane.
These versions all don't work:
Bitmap iBitmap = new
BitmapDrawable(ta.getResources().openRawResource(R.styleable.OnOffButton_iBitmap)).getBitmap();
Bitmap iBitmap = BitmapFactory.decodeResource(ta.getResources(),
R.styleable.OnOffButton_iBitmap);
DrawabledrwOnOff = ta.getDrawable( R.styleable.OnOffButton_iBitmap );
Bitmap iBitmap = Bitmap.createBitmap(drwOnOff.getIntrinsicWidth(),
drwOnOff.getIntrinsicWidth(), Config.ARGB_4444);
Canvas canvas = new Canvas(iBitmap);
drwOnOff.draw(canvas);
How can I read the iBitmap?
Thanks for helping me out on this.
Greetings,
Marco
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en