EditText点击后有时不能弹出软键盘,有时弹出软键盘后不能向EditText中输入内容,何解??

qinzhengdaren 2012-02-22 10:28:43
EditText点击后有时不能弹出软键盘,有时弹出软键盘后不能向EditText中输入内容,何解??
以下是xml配置文件的代码:

<EditText
android:id="@+id/reply_topic_content_txt"
android:gravity="top"
android:layout_width="match_parent"
android:layout_marginTop="10sp"
android:focusableInTouchMode="true"
android:focusable="true"
android:inputType="textMultiLine"
android:layout_height="110sp"
android:textSize="15sp">
<requestFocus></requestFocus>
</EditText>
...全文
1556 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
皓月明 2012-08-29
  • 打赏
  • 举报
回复
还是没有答案吗
叶子 2012-02-22
  • 打赏
  • 举报
回复
这里是下载频道,不解决技术问题,建议自行移动到:
移动平台--》Android板块。
叶子 2012-02-22
  • 打赏
  • 举报
回复

方法一:
在AndroidMainfest.xml中选择哪个activity,设置windowSoftInputMode属性为adjustUnspecified|stateHidden
例如:

<activity android:name=".Main" android:label="@string/app_name" android:windowSoftInputMode="adjustUnspecified|stateHidden" android:configChanges="orientation|keyboardHidden"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>

方法二:
让EditText失去焦点,使用EditText的clearFocus方法
例如:

EditText edit=(EditText)findViewById(R.id.edit); edit.clearFocus();

方法三:
强制隐藏Android输入法窗口
例如:

EditText edit=(EditText)findViewById(R.id.edit); InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(edit.getWindowToken(),0);

2.EditText始终不弹出软件键盘
例:

EditText edit=(EditText)findViewById(R.id.edit);
edit.setInputType(InputType.TYPE_NULL);

参考:
http://blog.csdn.net/strliu/article/details/6792434

786

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 非技术区
android小程序微信小程序 技术论坛(原bbs)
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧