有没有办法判断软键盘是否显示在活动中?
I tried
InputMethodManager manager = (InputMethodManager)
getSystemService(getApplicationContext().INPUT_METHOD_SERVICE);
manager.isActive(v)
but isActive仅在第一次显示键盘之前返回 false,但如果 kb 出现然后消失,isActive也返回 true。
那么有没有其他方法来检查这个问题。
thanks
根据这个POST http://groups.google.com/group/android-developers/browse_thread/thread/1c3291f15ed9c044/479f6233b27c5e30?pli=1
你无法检测到软键盘是否显示,但你可以通过知道软键盘是否显示来间接知道软键盘是否显示。View
您的活动的大小已调整。
想象一下你有一个ListView
并在底部EditText
,您希望在用户单击 EditText 后显示软键盘时转到列表底部。
你需要实现一个子类ListView
,然后在你的ListActivity
or Activity
or View
.
public class ThreadView extends ListView {
public ThreadView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
}
@Override
protected void onSizeChanged(int xNew, int yNew, int xOld, int yOld) {
super.onSizeChanged(xNew, yNew, xOld, yOld);
if (yOld > yNew) {
setSelection(((ListAdapter) getAdapter()).getCount() - 1);
}
}
}
希望这可以帮助
附言。 “检查配置更改”仅适用于手键盘。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)