关于EditText默认会弹出输入法的问题
2015-12-22 15:19
253 查看
最近遇到个问题app启动页面有个EdtiText(下面的edt)每次启动都会打开输入法,很是烦,网上找了下方法
有的说在前面的控件添加下面方法可以截断。。虽然我不知道有没有截断但是,输入框还是弹出来了、、
android:focusable="true"
android:focusableInTouchMode="true"
然后我只能把edt的获取焦点关闭了
android:focusable="false",
然后在edt的点击事件里面添加
edt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
edt.setFocusable(true);
edt.setFocusableInTouchMode(true);
edt.requestFocus();
edt.requestFocusFromTouch();
}
});
这样虽然是可以但是。要点两下才会弹出来输入框。
然后在网上看到了一片文章。↓第一个在清单文件里面添加的方法我觉得很好用。
第二个方法我试了也不行。
第三个也不行。。我不知道问什么。。
方法一:
在
AndroidMainfest.xml中选择哪个activity,设置windowSoftInputMode属性为 adjustUnspecified|stateHidden
<
activity android:name=".Main"
android:label="@string/app_name"
android:windowSoftInputMode="adjustUnspecified|stateHidden"
android:configChanges="orientation|keyboardHidden">
<
intent-filter>
<
action android:name="android.intent.action.MAIN" />
<
category android:name="android.intent.category.LAUNCHER" />
<
/intent-filter>
<
/activity>
方法二:
让
EditText失去焦点,使用EditText的clearFocus方法
例如:
EditText
edit=(EditText)findViewById(R.id.edit);
edit.clearFocus();
方法三:
强制隐藏Android输入法窗口
例如:
EditText
edit=(EditText)findViewById(R.id.edit);
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edit.getWindowToken(),0);
有的说在前面的控件添加下面方法可以截断。。虽然我不知道有没有截断但是,输入框还是弹出来了、、
android:focusable="true"
android:focusableInTouchMode="true"
然后我只能把edt的获取焦点关闭了
android:focusable="false",
然后在edt的点击事件里面添加
edt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
edt.setFocusable(true);
edt.setFocusableInTouchMode(true);
edt.requestFocus();
edt.requestFocusFromTouch();
}
});
这样虽然是可以但是。要点两下才会弹出来输入框。
然后在网上看到了一片文章。↓第一个在清单文件里面添加的方法我觉得很好用。
第二个方法我试了也不行。
第三个也不行。。我不知道问什么。。
方法一:
在
AndroidMainfest.xml中选择哪个activity,设置windowSoftInputMode属性为 adjustUnspecified|stateHidden
<
activity android:name=".Main"
android:label="@string/app_name"
android:windowSoftInputMode="adjustUnspecified|stateHidden"
android:configChanges="orientation|keyboardHidden">
<
intent-filter>
<
action android:name="android.intent.action.MAIN" />
<
category android:name="android.intent.category.LAUNCHER" />
<
/intent-filter>
<
/activity>
方法二:
让
EditText失去焦点,使用EditText的clearFocus方法
例如:
EditText
edit=(EditText)findViewById(R.id.edit);
edit.clearFocus();
方法三:
强制隐藏Android输入法窗口
例如:
EditText
edit=(EditText)findViewById(R.id.edit);
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(edit.getWindowToken(),0);
相关文章推荐
- JUC结构图
- Android Style之属性动画
- php 下 POST方法提交参数丢失问题
- IL2CPP的前世今生
- IL2CPP的前世今生
- ios...参数(不定参数)
- C语言printf函数格式化打印之长整型
- JQuery的链式操作
- JS控制图片显示的大小(图片等比例缩放)
- Android样式的开发之drawable
- 三星手机调用系统相机 activity被销毁
- 《Linux应用大全 基础与管理》一书,讲述日常系统管理内容
- Android入门之Activity四种启动模式(standard、singleTop、singleTask、singleInstance)
- 微博客户端授权的时候不回调WeiboAuthListener里面的方法
- C语言中a[++i],a[i++]
- java集合基础总结
- selenium操作日历控件(java版本)
- [网站公告]数据库服务器IOPS跑满造成网站不能正常访问
- Freemarker 常见语法大全
- Tomcat结合nginx使用小结