我不能使键盘在editText上动态可见。
//should show the Keyboard
editText.setFocusableInTouchMode(true);
editText.requestFocus();
final InputMethodManager mgr = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
//or this also does not work
mgr.toggleSoftInputFromWindow(editText.getWindowToken(),InputMethodManager.SHOW_FORCED ,InputMethodManager.HIDE_IMPLICIT_ONLY);下面是EditText的xml代码:
<EditText
android:id="@+id/searchHeaderView"
android:textSize="13dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:padding="5dip"
android:background="#00000000"
android:hint="@string/searchViewHint"
/>在同一个应用程序的另一个活动中,它与另一个EditText一起工作。
发布于 2013-10-21 02:19:53
这里有几个可以尝试的东西:
首先,要确保editText确实得到了关注。添加一个OnFocusChangeListener,然后在侦听器中放置一个断点或生成一些跟踪输出。
第二,在请求焦点和显示键盘之间设置一个延迟。如下所示:
post (new Runnable ()
{
@Override
public void run()
{
final InputMethodManager mgr = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}
});https://stackoverflow.com/questions/19478749
复制相似问题