我想在我的Android应用程序中放置一个EditText,它将保持相同的三个布局或更具体的EditText字段将可用于具有不同其他属性的三个活动(如不同的TextView,Button等)任何人都可以告诉我怎么能我这样做? 在此先感谢:)
答案 0 :(得分:0)
public class PhoneEditText extends EditText {
public PhoneEditText(Context context) {
super(context);
init();
}
public PhoneEditText(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public PhoneEditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
private void init() {
// set your input filter here
}
}
n XML layout you would simply use the full path to your custom class instead EditText:
<my.package.path.to.PhoneEditText android:id="@+id/one"
attribute="value (all EditText attributes will work as they did before)" />
<my.package.path.to.PhoneEditText android:id="@+id/two"
attribute="value (all EditText attributes will work as they did before)" />
that's it....