[英]How to show soft-keyboard when edittext is focused
I know their are 100 posts about this one, and somehow it isn't working for me. 我知道他们有100篇关于这个的文章,以某种方式对我来说不起作用。 I got an EditText, and when I "touch" that box, the keyboard must appear.
我得到一个EditText,并且当我“触摸”该框时,必须出现键盘。
This is everything I tried already: 这就是我已经尝试过的一切:
public void onClick(View v) {
EditText Edit_perceel_nr2 = (EditText)findViewById(R.id.Perceel_nr2);;
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(Edit_perceel_nr2.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
and 和
public void onClick(View v) {
EditText Edit_perceel_nr2 = (EditText)findViewById(R.id.Perceel_nr2);;
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(Edit_perceel_nr2.getWindowToken(), 0);
and 和
public void onClick(View v) {
EditText Edit_perceel_nr2 = (EditText)findViewById(R.id.Perceel_nr2);;
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(Edit_perceel_nr2, 0);
and 和
public void onClick(View v) {
EditText Edit_perceel_nr2 = (EditText)findViewById(R.id.Perceel_nr2);;
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(Edit_perceel_nr2, InputMethodManager.SHOW_IMPLICIT);
I even tried to add this in the manifest: 我什至尝试将其添加到清单中:
android:windowSoftInputMode="stateAlwaysVisible"
But I can't get it to work. 但是我无法正常工作。 Probably I forgot something, but I am out of ideas now.
可能我忘记了一些东西,但是现在我没主意了。 Someone got more ideas or the solution?
有人有更多的想法或解决方案吗?
This is my edittext: 这是我的edittext:
<EditText
android:id="@+id/Perceel_nr2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:text="text">
</EditText>
Try with this.. 试试这个..
EditText yourEditText= (EditText) findViewById(R.id.yourEditText);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(yourEditText, InputMethodManager.SHOW_IMPLICIT);
To Close u can use 关闭您可以使用
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(yourEditText.getWindowToken(), 0);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.