/*
* 隐藏光标和键盘的方法,传入的parent是editext的付布局
* */
private void cancleForce(RelativeLayout parent,EditText input){
parent.setFocusable(true);
parent.setFocusableInTouchMode(true);
try{
if(input.getText()==null||input.getText().equals("")){
}else {
input.setText("");
}
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(MainActivity.this.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}catch (Exception e){}
}
/*
* 获取光标的方法
* */
public void getForce(EditText input){
input.setFocusable(true);
input.setText("");
input.setFocusableInTouchMode(true);
input.requestFocus();
}
android editext光标隐藏和显示的方法
最新推荐文章于 2022-07-08 18:48:19 发布