我一直在用谷歌搜索这个主题,但没有找到相关信息。我很清楚如何扩展视图,但我不想扩展任何东西。
我想用自定义属性稍微“注释”哪个android视图(或任何视图的后代),然后在运行时检索它们的值。
像这样:
<TextView
custom:my_property_name="foo here"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/text_view"
android:text="Rule" />
然后,一旦我引用了这个 TextView,我想调用一个方法,例如:
String myProperty = textView.getProperty("my_property_name");
myProperty.equals("foo here");
这可能吗?如何?
谢谢。