1

Im developing an application and got stuck. i have a normal simple Button. What i want to do is that if i click this button it will behave just like you press the SPACE on the soft keyboard.

How do i do this. there must be a way because you can develop a softkeyboard.

So repeat xP How do i "inject" a keypress or simulate a keypress if i press a button.

Thank you! //Me

user564612
  • 45
  • 1
  • 8

1 Answers1

1
final EditText e = new EditText(context);
Button b = new Button(context);
b.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
        e.setText(e.getText().toString() + " ");
    }
});

click the button, append a space character to the EditText's value

this should be valid code, but i have not tested it

james
  • 26,141
  • 19
  • 95
  • 113