eks eks -5 years ago 202
Android Question

Adding a custom view to XML... but with a GENERIC-type

I am working on a custom view with a hope of reusability. It should have a generic type, like this:

public class CustomViewFlipper<someType> extends ViewFlipper { }

I know how to bind a normal custom view to the XML file. But I couldn't find any example for this situation. Is there any way to define a generic type for a class in XML?

Answer Source

I don't think so, but you can create your own subclass:

public class TheClassYouPutInTheLayoutFile extends CustomViewFlipper<someType>

and use that class in your layout XML.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download