[英]How come the Android soft keyboard is not responding to EditText?
I have a SherlockFragmentActivity and a SherlockFragment that is within a TabManager. 我有一个SherlockFragmentActivity和一个在TabManager中的SherlockFragment。 In this Fragment I have RadioButtons, CheckBoxes, a Button and an EditText in a LinearLayout.
在这个片段中,我在LinearLayout中有RadioButtons,CheckBoxes,Button和EditText。 The keyboard sometimes does not respond when pressing on the EditText.
按下EditText时键盘有时不响应。
In a 2.1 AVD the keyboard responds inconsistently, in a 4.0 AVD the keyboard does not respond at all, and on a device the keyboard responds inconsistently. 在2.1 AVD中键盘响应不一致,在4.0 AVD中键盘根本不响应,而在设备上键盘响应不一致。 Sometimes pressing the other objects then activates the ability to show the keyboard.
有时按下其他对象然后激活显示键盘的能力。
Here is the XML for the EditText: 这是EditText的XML:
<EditText android:id="@+id/EditText1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:inputType="number"
android:text="20" >
I'm confused of the inconsistent activity more so than the fact that it doesn't work on the 4.0 AVD. 我对不一致的活动感到困惑,因为它不适用于4.0 AVD。 Any suggestions to why this is happening or a way to show the keyboard would be great.
任何关于为什么会发生这种情况的建议或者显示键盘的方式都会很棒。
You can register a focus listener for your edittext and open soft keyboard when it get focus: 您可以为edittext注册焦点侦听器,并在获得焦点时打开软键盘:
edit_Text.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus){
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE))
.showSoftInput(edit_Text, InputMethodManager.SHOW_FORCED);
}else
Toast.makeText(getApplicationContext(), "lost the focus", 2000).show();
}
});
Edit: 编辑:
For emulator
,I think that it is not guaranteed.Really I did not any way to appear soft keyboard programmatically.Some times it appears and some times not.In emulator with android 4.0.3,you can see a symbol in notification bar instead of appearing soft keyboard: 对于
emulator
,我认为它不能保证。实际上我没有任何方式以编程方式出现软键盘。有时它出现,有时不出现。在Android 4.0.3的模拟器中,你可以在通知栏中看到一个符号而不是出现软键盘:
Look at: 看着:
Event for Handling the Focus of the EditText 处理EditText焦点的事件
Forcing the Soft Keyboard open 强制打开软键盘
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.