开发者

android input method problems

A few questions about android:

Is it possible to replace the keys in default keyboards ? For example, is it possible to replace the dot in the numeric keyboard with a comma ?

I wrote a very simple IME, but I cannot set it to an EditText. What I want is to set one of m开发者_如何转开发y EditText to use the IME I wrote by default, not the default LatinIME. Is that possible ? How inputMethod attribute works ? I set the fully qualified class name of IME but it raises class not found exception.

Thanks.


Is it possible to replace the keys in default keyboards ? 

You don't. Users are in control over their device, including what keyboard gets used.

But You can try to make some input methods

Read this tutorial: Creating an Input Method

clone this repo: LatinIME

And if replacing one character is your requirement, you can override text change listener of edittext, and check each entered character and if user entered dot then replace that with comma as

editText.addTextChangedListener(new TextWatcher(){
        public void afterTextChanged(Editable s) {
           //Check if s contains dot and replace it with comma
        }
        public void beforeTextChanged(CharSequence s, int start, int count, int after){}
        public void onTextChanged(CharSequence s, int start, int before, int count){}
    });  

But this method executes each key hit in EditText.


try override this method.return another keyCode and see the reslt

@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {

        if (keyCode == someKeyCode) {
          //...... button is pressed
        }
        return super.onKeyDown(keyCode, event);
    }


Pretty sure replacing keys in the default keyboard is not possible, you would need to write your own keyboard replacement, much like all the keyboard Apps do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜