0

我知道他们有100个关于这个的帖子,不知何故它不适合我。 我得到了一个EditText,当我“触摸”那个盒子时,键盘必须出现。如何在edittext集中时显示软键盘

这一切我已经试过:

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); 

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); 

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); 

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); 

我甚至试图在清单中加入:

android:windowSoftInputMode="stateAlwaysVisible" 

但我无法让它工作。 也许我忘了一些东西,但我现在没有想法。 有人有更多的想法或解决方案?

这是我的EditText:

<EditText 
    android:id="@+id/Perceel_nr2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:inputType="number" 
    android:text="text"> 
</EditText> 
+0

据我知道你并不需要做任何事情来显示键盘。只需添加您的EditText并且不要为它设置onClick! – caiocpricci2 2012-02-28 09:12:39

+0

哦,没有onClick是一个按钮,当我点击一个按钮,然后他必须做一些行动,这就是其中之一。 – Bigflow 2012-02-28 09:15:42

+0

你是如何创建你的编辑文本? – caiocpricci2 2012-02-28 09:16:35

回答

4

尝试用这个..

EditText yourEditText= (EditText) findViewById(R.id.yourEditText); 
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
imm.showSoftInput(yourEditText, InputMethodManager.SHOW_IMPLICIT); 

,收u可以使用

InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); 
imm.hideSoftInputFromWindow(yourEditText.getWindowToken(), 0); 
+0

啊,我是个盲人-.-,我使用'hideSoftInputFromWindow'而不是'showSoftInputFromWindow',我已经在这个问题上看了3个小时(喝咖啡的时间?) – Bigflow 2012-02-28 09:25:20

+0

我现在已经删除了'InputMethodManager',并且它现在也能工作,现在也没有强制键盘显示代码。 – Bigflow 2012-02-28 09:34:42

相关问题