typeoneerror
typeoneerror

Reputation: 56968

Define custom Android components using short namespace?

Working on my first Android application. I'm wondering if there's a way to use the xmlns in the markup in any way. In Flex, for example, I can define a namespace:

<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:cb="com.typeoneerror.apps.app.views.components.*">
    <cb:CustomComponent paramName="demo"></cb:CustomComponent>
</mx:VBox>

Android seems to be slightly different. You use the namespace when defining params but not the tag itself. This is a bit wordy to me, so I'm wondering if there's a way to configure or change this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:cb="http://schemas.android.com/apk/res/com.typeoneerror.apps.app">
    <com.typeoneerror.apps.app.views.components.CustomComponent cb:paramName="demo"/>
</LinearLayout>

I'd like to use

<cb:CustomComponent cb:paramName="demo"></cb:CustomComponent>

Possible?

Upvotes: 7

Views: 754

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007399

No, sorry. The element name is a Java class name, and in the case of custom widgets, is a fully-qualified class name.

I have seen some syntax where the element name is View and there is a class attribute with the widget's class name. I can't find that in the docs and don't have an sample available, though.

Upvotes: 2

Related Questions