【发布时间】:2017-08-17 18:27:26
【问题描述】:
如何在我的 Activity 类中获取“必需”属性值?
1.值\attrs.xml
<declare-styleable name="EditText">
<attr name="required" format="boolean" />
</declare-styleable>
2。布局\text.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res/com.mycompany.test"
android:baselineAligned="false"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/txtTest"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:inputType="text"
custom:required="true" />
【问题讨论】:
-
你找到答案了吗?我正在为同样的问题而苦苦挣扎:)