1.代码:
edittext = findViewById(R.id.edittext);
edittext.setShowSoftInputOnFocus(false);//点击输入框时不显示系统键盘
edittext.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus){
mySoftInput.setVisibility(View.VISIBLE);//显示自定义键盘
}
}
});
edittext.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
edittext.setSelection(s.length());//光标后移
}
@Override
public void afterTextChanged(Editable s) {
}
});