android 应用程序中有没有办法检索在 a 中声明的小部件的属性值layout.xml
?
例如在我的layout.xml文件中,我有:
<CheckBox
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/clean_filesWithoutVideo"
android:checked="@{uiprefs.switchButtonEditable}"
android:id="@+id/checkbox_updateable" />
我想检索 的文字值android:checked
,例如我想"@{uiprefs.switchButtonEditable}"
在运行时检索。
我在android.content.res.Resources
课堂上使用getResources()
Activity 进行搜索但没有成功:
- 我无法将 xml 文件作为流获取。
- 通过 解析属性
Resources.getLayout()
不会恢复属性值。
也许这个值隐藏在CheckBox
实例中的某个地方,但我在调试时使用检查找不到它......
注意:我要检索的值尤其是数据绑定文字。也许我可以通过数据绑定 API 检索它?