添加自定义视图XML ...但与通用型 [英] Adding a custom view to XML... but with a GENERIC-type
本文介绍了添加自定义视图XML ...但与通用型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的工作与重用的希望自定义视图。它应该有一个泛型类型,就像这样:
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 { }
我知道如何绑定一个正常的自定义视图的XML文件。但我无法找到这种情况的例子。有什么办法来定义XML一类的泛型类型?
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?
推荐答案
我不这么认为,但你可以创建自己的子类:
I don't think so, but you can create your own subclass:
public class TheClassYouPutInTheLayoutFile extends CustomViewFlipper<someType>
和使用该类在布局XML。
and use that class in your layout XML.
这篇关于添加自定义视图XML ...但与通用型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文