我已覆盖this link中给出的EditText。
现在在我正在使用的布局中声明此字段时
<com.and.ab1209.ClearableEditText
android:id=”@+id/edit_text_clearable”
android:layout_width=”fill_parent”
android:hint="My Hint Goes here"
android:layout_height=”wrap_content” />
我如何在任何这些构造函数中检索此提示值。
public ClearableEditText(Context context, AttributeSet attrs, int defStyle){...}
public ClearableEditText(Context context, AttributeSet attrs){...}
我该怎么做?
您可以通过在视图构造函数中执行以下操作来访问标准xml属性:
您无法访问“ android”属性。您可以在调用getHint()
构造函数之后使用super()
。如果要创建自己的属性,请遵循this tutorial。
在构造函数中使用this.getHint()
您可以通过在您的属性集中定义android-namespaced属性来使用它。例如: