1.阻止手动输入

//设置EditText可以点击但是不可以输入
		edCity.setCursorVisible(false);
		edCity.setFocusable(false);
		edCity.setFocusableInTouchMode(false);

2.取消EditText弹出的软键盘
  1.在Manifest.xml文件中相应的activity下添加一下代码:
   android:windowSoftInputMode=“stateHidden”

  2.让EditText失去焦点,使用EditText的clearFocus方法
   例如:EditText edit=(EditText)findViewById(R.id.edit);
   edit.clearFocus();

  3.强制隐藏Android输入法窗口
   例如:EditText edit=(EditText)findViewById(R.id.edit);
   InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
   imm.hideSoftInputFromWindow(edit.getWindowToken(),0);

  4.EditText始终不弹出软件键盘
   例:EditText edit=(EditText)findViewById(R.id.edit);
   edit.setInputType(InputType.TYPE_NULL);

  5.在EditText标签的外层Layout中加入focusableInTouchMode属性

<LinearLayout android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:focusableInTouchMode = "true">
			<EditText>...</EditText>
</LinearLayout >
Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐