开发者

Android soft keyboard showing problem

I'm trying to control soft keyboard using this:

((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE))
            .hideSoftInputFromInputMethod(filterText.getWindowToken(), 0);
((InputMethodManager) getSystemService(Co开发者_StackOverflow社区ntext.INPUT_METHOD_SERVICE))
            .showSoftInput(filterText, InputMethodManager.SHOW_IMPLICIT);

But nothing happens on the device when i call this code. What can cause such behavior?


If you have a

EditText mEditText;

then you should set:

InputMethodManager imm = (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(mEditText, InputMethodManager.SHOW_FORCED);

For a textview,

TextView mtextview;

you can set:

android:focusableInTouchMode="true"

android:inputType="text"

in the xml file. Upon clicking on the textview, you will pop up the keyboard.


I was having an issue where the soft keyboard was showing up when I first entered the activity and I didn't want it to. This was messing up my scrollview. I was able to keep if from doing this by setting the following in the manifest file in the activity that I was dealing with: android:windowSoftInputMode="stateHidden"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜