On Tue, Jul 10, 2012 at 11:40 PM, H57 <[email protected]> wrote: > I want to add application related metadata to <EditText>. For example, > something like this > > <EditText > android:id="@+id/age" > <android:metadata> > <name="maxAllowedForKids" value="15"> > <name="maxAllowedForAdult" value="100"> > <name="somethingelse" value="9999"> > </android:metadata> > ........... > > How can we add some application related metadata to a EditText ?
I think this works: Step #1: Add your own namespace (e.g., xmlns:tanwarhemant="http://www.tanwarhemant.com/xmlns") Step #2: Add attributes in that namespace (e.g., tanwarhemant:maxAllowedForKids="15") Step #3: Read in the layout resources yourself, using getResources().getXml(), passing in the R.layout.whatever ID of your layout resource to getXml() Personally, I wouldn't do this, at least for the sort of thing that you are describing. maxAllowedForKids is a controller concept IMHO; EditText should not care about that. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 3.8 Available! -- 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

