Android,无法使用InputMethodManager使键盘可见
我无法使键盘在editText上动态可见Android,无法使用InputMethodManager使键盘可见,android,keyboard,android-edittext,Android,Keyboard,Android Edittext,我无法使键盘在editText上动态可见 //should show the Keyboard editText.setFocusableInTouchMode(true); editText.requestFocus(); final InputMethodManager mgr = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
//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一起工作。以下是一些可以尝试的东西: 第一,确保编辑文本实际上得到了关注。添加OnFocusChangeListener,然后在侦听器中放置断点或生成一些跟踪输出 第二,在请求对焦和显示键盘之间设置延迟。像这样:
post (new Runnable ()
{
@Override
public void run()
{
final InputMethodManager mgr = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}
});
我希望你正在进步。如果我的回答对你有帮助,请把票投上去或标上正确的分数。这有助于你赢得声誉,也有助于其他人更容易找到有用的答案。