EditText如何屏蔽软键盘? 好像可以在edittext控件中屏蔽掉 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import android.view.inputmethod.InputMethodManager; private InputMethodManager mIM; mIM = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);EditText ipNumber = (EditText) popupBody .findViewById(R.id.alertdialogedit);//ipNumber就是EditText handler.postDelayed(new Runnable() { public void run() { imm.hideSoftInputFromWindow(ipNumber.getWindowToken(), 0); } }, 200); private Handler handler = new Handler() { public void handleMessage(Message msg) { switch (msg.what) { case 0: System.out.println("DONE"); break; } } };这个我实现过,作用是启动的时候不弹出键盘,可以把这代码加到onCreate里面,但是必须延迟200毫秒以上,如果不加延迟发现没有效果。楼主试试看,实现肯定是没有问题的。有问题继续留意。 如果你是点击的时候不需要他,就加一个点击监听器,然后在onClick里面加imm.hideSoftInputFromWindow(ipNumber.getWindowToken(), 0);就可以了。 import android.view.inputmethod.InputMethodManager; private InputMethodManager mIM; mIM = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);EditText ipNumber = (EditText) popupBody.findViewById(R.id.alertdialogedit);//ipNumber就是EditText ipNumber.setOnClickListener(new OnClickListener(){ @Override public void onClick(DialogInterface arg0, int arg1) { imm.hideSoftInputFromWindow(ipNumber.getWindowToken(), 0); } })你也可以加focus改变的监听器setOnFocusChangeListener,这样焦点改变的时候就加隐藏的代码。 EditText.setInputType(InputType.TYPE_NULL); AndroidManifest.xml 文件中Application 中加上android:windowSoftInputMode="adjustUnspecified" 让代码说话 O(∩_∩)O~在android的开发中,将整个页面只使用LinearLayout编辑时,当点击输入框时,系统自带的虚拟键盘会遮挡住输入框解决办法是在整个页面配置文件中,在LinearLayout布局外加入<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/backgroundshape">这样在系统自动调用虚拟键盘时,整个页面布局会发生变化,分为两个部分,一个是虚拟键盘显示的部分,一个是你自己的页面。 android异步刷新界面的问题 ListView&SimpleAdapter ndk中编译stl报错 android system service为什么都@Override一个dump函数? android pull解析器解析xml文档报错XmlPullParserException,求解决 定位问题 请问下..android怎么获取账户和同步的状态 关于SurfaceView使用Animation。 android aidl 求解释! GoogleMap 使用问题 程序运行之后出错 android怎样把文本数据读、写到sd卡上,以文本文件的方式读写?
private InputMethodManager mIM;
mIM = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
EditText ipNumber = (EditText) popupBody
.findViewById(R.id.alertdialogedit);//ipNumber就是EditText
handler.postDelayed(new Runnable() {
public void run() {
imm.hideSoftInputFromWindow(ipNumber.getWindowToken(), 0); }
}, 200);
private Handler handler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case 0:
System.out.println("DONE");
break;
}
}
};
这个我实现过,作用是启动的时候不弹出键盘,可以把这代码加到onCreate里面,但是必须延迟200毫秒以上,如果不加延迟发现没有效果。楼主试试看,实现肯定是没有问题的。有问题继续留意。
private InputMethodManager mIM;
mIM = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
EditText ipNumber = (EditText) popupBody
.findViewById(R.id.alertdialogedit);//ipNumber就是EditText
ipNumber.setOnClickListener(new OnClickListener(){ @Override
public void onClick(DialogInterface arg0, int arg1) {
imm.hideSoftInputFromWindow(ipNumber.getWindowToken(), 0);
}
})
你也可以加focus改变的监听器setOnFocusChangeListener,这样焦点改变的时候就加隐藏的代码。
解决办法是在整个页面配置文件中,在LinearLayout布局外加入
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@drawable/backgroundshape">
这样在系统自动调用虚拟键盘时,整个页面布局会发生变化,分为两个部分,一个是虚拟键盘显示的部分,一个是你自己的页面。