tags:

views:

280

answers:

2

Hi.

We have in our project a keyboard with "Key" elements, this Key elements have attributes such as android:codes="119", android:keyLabel="w" and so on.

My question is how can I include an custom attribute like a "android:alternativeKeyLabel" to do something else.

A: 

android:keyLabel is one of many XML attribute used by the Keyboard.Key class for each key on your keyboard. android:keyLabel is what you want to label the key with (like a "w" as in above). The attributes are pre-defined for the class. The "w" isn't but android:keyLabel is. If you could create android:alternativeKeyLabel what would you expect the class to do with it? I think maybe you should try to explain further what you are trying to accomplish.

fupsduck
+1  A: 

You can create custom attributes for your own classes that extend View or a subclass. The process is documented in the "Available Resource Types" section of the Android Dev Guide under the heading "Custom Layout Resources":

http://developer.android.com/intl/fr/guide/topics/resources/available-resources.html#customresources

There is an example in the API Demos called LabelView:

http://developer.android.com/intl/fr/resources/samples/ApiDemos/src/com/example/android/apis/view/LabelView.html

http://developer.android.com/intl/fr/resources/samples/ApiDemos/res/values/attrs.html

Lance Nanek