EditText监听焦点变化

1.设置光标可见

android:cursorVisible="true"


2.设置光标在最后

CharSequence text = asw_wifi_account_et.getText();
if (text instanceof Spannable) {
	Spannable spanText = (Spannable)text;
	Selection.setSelection(spanText, text.length());
}
或者

asw_wifi_account_et.setSelection(currentSSID.length());


3.监听变化

editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
			@Override
			public void onFocusChange(View view, boolean hasFocus) {
				if(hasFocus){ //获得焦点
					ToastUtils.showToast(mContext,"获得焦点");
				}else{//失去焦点
					ToastUtils.showToast(mContext,"失去焦点");
				}
			}
		});



你可能感兴趣的:(布局-控件,EditText监听焦点)