【发布时间】:2018-11-08 01:31:16
【问题描述】:
我有这样的结构:
preferences.xml:
...
<com.example.MyCustomPreference
...
myCustomMessage="@string/abc"
android:inputType="..."
... />
...
preference_my_custom.xml:
<LinearLayout ...>
<com.example.MyCustomView
...
app:myCustomMessage="?????"
... />
</LinearLayout>
view_my_custom.xml:
<GridView ...>
...EditTexts, TextViews, etc.
</GridView>
我想使用 XML 将 myCustomMessage 的值(为了简化我省略了其他属性)从 MyCustomPreference 传递给 MyCustomView。 MyCustomView 读取自定义属性,所以我想避免以编程方式读取 MyCustomPreference 中的属性,从 MyCustomView 获取 TextViews 并设置它们的值。但是,我真的不知道用什么来代替“??????”。
我怎样才能使用 XML 做到这一点?这可能吗?
【问题讨论】:
-
我看过了。我认为我的问题略有不同。我不使用
,也不想使用对资源的引用,而是使用已经作为属性传递的值。 -
您的问题略有不同,但据我所知,解决方案是相同的(数据绑定)
-
乐于助人:)
标签: android android-custom-view attr