我知道可以在 xml 上设置自定义属性及其值,但是,可以稍后在运行时更改该值吗?
我有这个xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:example="http://schemas.android.com/apk/res/ValidatedButton.ValidatedButton"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<validatedbutton.ValidatedButton
android:id="@+id/myButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/icon_selector"
example:state_valid="false"
android:text="@string/hello" />
</LinearLayout>
我想在运行时将 example:state_valid 更改为 true 或 false。