[英]Soft keyboard doesn't appear
I'm testing my app on android 4.0.4 Samsung galaxy duos, the problem is if I set: 我正在android 4.0.4 Samsung galaxy duos上测试我的应用程序,问题是是否设置了:
android:textIsSelectable="true"
the keyboard doesn't appear, though it appears on the emulator. 键盘虽然出现在模拟器上,但没有出现。 Any suggestions?
有什么建议么?
Here is how my EditBox
looks like 这是我的
EditBox
样子
<EditText
android:focusable="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textVisiblePassword|textCapWords|textMultiLine"
android:textIsSelectable="true"
android:gravity="top|left"
android:minLines="6"
android:maxLines="10"
android:minHeight="140dp"
android:hint="@string/message"
/>
<requestFocus />
Add a requestfocus. 添加一个requestfocus。 In xml:
在xml中:
<EditText>
<requestFocus />
</EditText>
Programmatically 以编程方式
edittext.requestFocus();
To "force" the SoftKeyboard to appear, you can do it dynamically: 要“强制”出现软键盘,可以动态进行操作:
InputMethodManager mImm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
mImm.showSoftInput(SearchEdit, InputMethodManager.SHOW_IMPLICIT);
Set onFocusChangeListener to appear your keyboard: 设置onFocusChangeListener以显示键盘:
edittext.setFocusable(true);
edittext.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus)
mImm.showSoftInput(SearchEdit, InputMethodManager.SHOW_IMPLICIT);
else
mImm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);
}
});
See InputMethodManager Documentation for more information. 有关更多信息,请参见InputMethodManager文档 。
See also these answers to forcing the Keyboard to appear: Forcing the Soft Keyboard open 另请参阅以下有关强制显示键盘的答案: 强制打开软键盘
You need to put requestFocus
inside EditText
element: 您需要将
requestFocus
放在EditText
元素内:
<EditText
android:focusable="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textVisiblePassword|textCapWords|textMultiLine"
android:textIsSelectable="true"
android:gravity="top|left"
android:minLines="6"
android:maxLines="10"
android:minHeight="140dp"
android:hint="@string/message">
<requestFocus />
<EditText/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.