1.监听点击EditText,弹出软键盘中的Enter键:
edittext.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
//when Enter Key is press,do business
return true;
}
});
2.监听EditText焦点的改变:
ecode.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) {
//do something
}else if(hasFocus){
//do something
}
}
});
3.为EditText的上下左右添加图片,调用其父类TextView的方法即可:
void android.widget.TextView.setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom);