Diego
Diego

Reputation: 4101

Imitate keytouch

I created a keypad from buttons (so an xml with button 1, button 2, etc., but now I want an edit text to react the same as using the soft-keyboard, is there a way to imitate the keypad that comes with the device?

Upvotes: 0

Views: 58

Answers (1)

Raghunandan
Raghunandan

Reputation: 133570

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

      //show your custom keypad
       }
   } 
});

Force softkeypad to appear.

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

Upvotes: 1

Related Questions