0

私は彼らがこれについて100の投稿をしていることを知っていますが、どういうわけか私にとってはうまくいきません. 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
    android:id="@+id/Perceel_nr2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="number"
    android:text="text"> 
</EditText>
4

1 に答える 1

4

これで試してみてください..

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

閉じるには、使用できます

  InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
 imm.hideSoftInputFromWindow(yourEditText.getWindowToken(), 0);
于 2012-02-28T09:17:11.793 に答える