answering my own question again here:
the problem below was because the parse was no longer on the Keyboard tag
but was on one of the key tags it could not look "back" a the values defined
by the keyboard. once i got that and moved the code to a place where the
keyboard is parsed it started working.

On Fri, Aug 28, 2009 at 3:16 AM, Spektor Yaron <spekt...@gmail.com> wrote:

> Hi,
> i was wondering if anyone could give me hints on this one (i am re-posting
> an older version of a question i once had):
> i created a new attrs.xml that adds some functionality to the soft keyboard
> sample code.
> i would appreciate any insight you may have on this:
>
> 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" />
>        ....
>        ....
>          <!-- The image used for keys  -->
>         <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 layout 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
> The line below DOESN'T WORK! (has null value) - WHY????
> BitmapDrawable orgBmpDraw=
> (BitmapDrawable)a1.getDrawable(R.styleable.Keyboard_keysImg);
>
> TypedArray a = res.obtainAttributes(Xml.asAttributeSet(parser),
> R.styleable.Keyboard_Key);
> //the kine below WORKS!
> BitmapDrawable orgBmpDraw=
> (BitmapDrawable)a.getDrawable(R.styleable.Keyboard_Key_keysImgTemp);
> //The kine below DOESN'T WORK - has null value - I eventually solved it by
> changing the attribute from android: to jk: so i needed to override the
> existing internal attr.xml with mine
> BitmapDrawable orgBmpDraw=
> (BitmapDrawable)a.getDrawable(R.styleable.Keyboard_Key_keyIcon);
>
> what am i missing here?
> thanks,
>
>
> --
> Yaron Spektor
>



-- 
Yaron Spektor

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to