Android API with custom view ids
For things like embedded Android ListView
, you can reference IDs in XML by doingandroid:id="@android:id/text1"
Let's say I have an external library called MyDomain
in which I have some useful linking APIs.
In my main application, I would like to do something like android:id="@mydomain:id/someTextId"
.
How can i do this?
I am using Android Studio Beta 0.8.6 and (for now) have the library as a module if it matters
This post has a good explanation of How to reference a string from another package in a library using XML in Android? by the meaning "package" is there and why you can't use it like that unless you are using shared libraries
I'm not sure I understand what you exactly want to do ...
You can share your library component with your application. The application layout will be something like this:
<com.my.domain.MyComponent
xmlns:android="http://schemas.android.com/apk/res/android"
...
/>
You can also define custom properties for your component directly in the layout by adding an XML namespace, for example:
xmlns:md="http://schemas.android.com/apk/res/com.my.domain.MyComponent"
And then you can use the type property md:my_property="42"
.
Also check this answer: How to set up custom namespaces in layout file in android studio?