2013-03-17 73 views
0

我從按鈕創建了一個小鍵盤(所以xml的按鈕1,按鈕2等,但現在我想要一個編輯文本的反應與使用軟鍵盤相同,有沒有一種方法來模仿出現自帶的設備鍵盤?模仿keytouch

+0

只需更新使用的setText()在onclick()你的按鈕 – 2013-03-17 15:34:44

+0

的方法,但是,如果有人點擊了什麼的EditText文字的中間要半途編輯它? – Diego 2013-03-17 16:02:52

回答

1
editText.setOnFocusChangeListener(new View.OnFocusChangeListener() { 
@Override 
public void onFocusChange(View v, boolean hasFocus) { 
    if (hasFocus) { 

     //show your custom keypad 
     } 
    } 
}); 

力softkeypad。

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