I'd like to write my own software keyboard on android.
I've found this blog post:
http://android-developers.blogspot.ru/2009/04/creating-input-method.html
Also i have found SoftwareKeyboard
sample in android samples.
I compiled apk and installed it in emulator. I've selected my keyboard in Settings / Language & Keyboard but my software keyboard is not shown when i focus any editable control in another apps. I expect to see button with text "hey!" instead of keyboard:
/**
*
*/
public class KeyboardsService extends InputMethodService {
private View view;
@Override
public View onCreateInputView() {
Button button = new Button(this);
button.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.FILL_PARENT,
200 // 200 px
));
button.setText("hey!");
view = button;
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// send "Enter" on click
sendDownUpKeyEvents(KeyEvent.KEYCODE_ENTER);
}
});
return view;
}
}
So what's wrong? The same problem with SampleKeyboard
sources - it's listed in software keyboards list but not shown. I can see default keyboard is checked and not available. Is this the reason?