Làm cách nào để nhận giá trị thuộc tính "bắt buộc" trong Lớp hoạt động của tôi?Android: Cách nhận thuộc tính tùy chỉnh của XML trong lớp Hoạt động
1. giá trị \ attrs.xml
<declare-styleable name="EditText">
<attr name="required" format="boolean" />
</declare-styleable>
2. bố trí \ 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" />
Bạn có thấy câu trả lời? Tôi đang đấu tranh với cùng một câu hỏi :) –