Hi,
i was wondering if anyone could give me hints on this one:
i created a new attrs.xml that adds some functionality to the soft keyboard
sample code.
i added: <attr name="keysImg" format="reference" /> to:
<declare-styleable name="Keyboard">
<!-- Default width of a key, in pixels or percentage of display
width -->
<attr name="keyWidth" format="dimension|fraction" />
<!-- Default height of a key, in pixels or percentage of display
width -->
<attr name="keyHeight" format="dimension|fraction" />
<!-- Default horizontal gap between keys -->
<attr name="horizontalGap" format="dimension|fraction" />
<!-- Default vertical gap between rows of keys -->
<attr name="verticalGap" format="dimension|fraction" />
<!-- The global image used to crop keys from -->
<attr name="keysImg" format="reference" />
</declare-styleable>
and added: <attr name="keysImgTemp" format="reference" /> to:
<declare-styleable name="Keyboard_Key">
.....
<attr name="keyIcon" format="reference" />
<attr name="keysImgTemp" format="reference" />
......
</declare-styleable>
in the xml file the data look like this:
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:jk="
http://schemas.android.com/apk/res/com.example.android.softkeyboard"
......
jk:keysImg="@drawable/sym_keyboard_shift"
>
and the key looks like this:
<Key android:codes="49" android:keyIcon="@drawable/sym_keyboard_shift"
jk:keysImgTemp="@drawable/keypad1low"/>
in my code i try to reference these values
TypedArray a1 = res.obtainAttributes(Xml.asAttributeSet(parser),
R.styleable.Keyboard);//get all attrs for the keyboard as defined in
attrs.xml
THIS DOESN'T WORK! (has null value)
BitmapDrawable orgBmpDraw=
(BitmapDrawable)a1.getDrawable(R.styleable.Keyboard_Key_keysImg);
TypedArray a = res.obtainAttributes(Xml.asAttributeSet(parser),
R.styleable.Keyboard_Key);
//THIS WORKS!
BitmapDrawable orgBmpDraw=
(BitmapDrawable)a.getDrawable(R.styleable.Keyboard_Key_keysImgTemp);
//THIS DOESN'T WORK - has null value
BitmapDrawable orgBmpDraw=
(BitmapDrawable)a.getDrawable(R.styleable.Keyboard_Key_keyIcon);
what am i missing here?
thanks,
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---