您的位置:首页 > 移动开发 > Android开发

android平板上EditText总是自动弹出输入法问题

2014-09-16 10:40 507 查看
在网上搜索了好多方法,如:

1、 在AndroidManifest.xml activity标签加入 android:windowSoftInputMode="stateVisible|adjustPan"

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);

都不好使,都没啥用。

最后在每个在EditText前面放置一个看不到的LinearLayout,让他率先获取焦点:

<LinearLayout 
android:focusable="true" 
android:focusableInTouchMode="true" 
android:layout_width="0px" 
android:layout_height="0px"/>

这样就完美解决了editText自动弹出输入法的问题。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: