本文介绍了软键盘不会出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我测试我在Android 4.0.4三星galaxy二重奏应用,那么问题是,如果我设置:
的android:textIsSelectable =真
键盘没有出现,虽然它出现在模拟器。有什么建议?
下面是如何我编辑框
看起来
<的EditText 机器人:可聚焦=真
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
安卓的inputType =textVisiblePassword | textCapWords | textMultiLine
机器人:textIsSelectable =真
机器人:重力=顶|左
安卓的minlines =6
机器人:MAXLINES =10
安卓了minHeight =140dp
机器人:提示=@字符串/消息
/>
< requestFocus的/>
解决方案
添加requestFocus的。
在XML:
<&的EditText GT;
< requestFocus的/>
< /&的EditText GT;
编程
edittext.requestFocus();
要强制的SoftKeyboard出现,可以动态地做到这一点:
InputMethodManager mImm =(InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
mImm.showSoftInput(SearchEdit,InputMethodManager.SHOW_IMPLICIT);
设置onFocusChangeListener出现键盘:
edittext.setFocusable(真);
edittext.setOnFocusChangeListener(新View.OnFocusChangeListener(){
@覆盖
公共无效onFocusChange(视图V,布尔hasFocus){
如果(hasFocus)
mImm.showSoftInput(SearchEdit,InputMethodManager.SHOW_IMPLICIT);
其他
mImm.hideSoftInputFromWindow(edittext.getWindowToken(),0);
}
});
请参阅了解详情。结果
查看也是这些答案迫使键盘出现:强制打开软键盘
I'm testing my app on android 4.0.4 Samsung galaxy duos, the problem is if I set:
android:textIsSelectable="true"
the keyboard doesn't appear, though it appears on the emulator. Any suggestions?
Here is how my EditBox
looks like
<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.In 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:
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.
See also these answers to forcing the Keyboard to appear: Forcing the Soft Keyboard open
这篇关于软键盘不会出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!