xml中的Android参数化视图



我一直在寻找一种在布局中声明参数化视图的方法。例如,如果我有一个类NumericTextView<T> extends TextView,我希望能够在xml布局中声明它。由于布局的解析方式,以下内容似乎不起作用。

<NumbericTextView<Integer>/>

但我可能有这样的东西吗?

<NumbericTextView type:Integer/>

如果这仍然不起作用,那么使用一些自定义的FrameLayout来打开参数以添加正确的NumbericTextView<T>子项有什么问题吗?

您将想要执行以下操作:

<com.my.ui.NumericTextView
    android:id="@+id/MyTextView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />

请参阅安卓自定义文本视图无法添加在布局文件中

对于自定义属性:http://prasanta-paul.blogspot.com/2010/05/android-custom-textview.html

最新更新