国信选择未出现 [英] National letter selector doesn't appear

查看:161
本文介绍了国信选择未出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要做的就是实现一个文本输入哪些颜色的字母上绿色或红色。我的code的一块能做到这一点,但有一些明显的问题。当我试图写一个国信我不能因为选择它不会出现弹出。什么是更奇怪我的硬件键盘我的HTC没有这个问题。

What I have to do is implement a text input which colors letters on green or red. My piece of code can do this but there is obviously some problem. When I'm trying write an national letter I just can't because popup for select it not appears. What is more strange my hardware keyboard in my htc doesn't have this problem.

edit_text.addTextChangedListener(new TextWatcher() {
    boolean input_changed = false;        

    private boolean isInputBlocked()
    {
        this.input_changed = !this.input_changed;                
        return !this.input_changed;                
    }

    @Override
    public void afterTextChanged(Editable s) 
    {
        // Prevent recursive 
        if (isInputBlocked()) return;                                

        // Some staff                                                

        Outer.this.edit_text.setText(Html.fromHtml(html_input.toString()));
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count,
            int after) {}

    @Override
    public void onTextChanged(CharSequence s, int start, int before,
            int count) 
    {}        
});


当我评论的 Outer.this.edit_text.setText(Html.fromHtml(html_input.toString())); 的那么软键盘做工不错

问题


  1. 什么是错的?难道是一些在Android的错误?

  2. 有一些优雅的方式去解决?

  3. 是我实现的递归良好的prevention的?可能是更优雅?

感谢。

推荐答案

好吧,我已经找到解决方案。它可以使用输入过滤来完成。也许有人会有所帮助。

Ok, I have found solution. It could be done using the InputFilter. Maybe for someone it will be helpful.

InputFilter filter = new InputFilter() {
        final String good_letter = "<font color='#2FEE0D'>$</font>";
        final String bad_letter = "<font color='#FF0000'>$</font>";

        public CharSequence filter(CharSequence source, int start, int end, 
                Spanned dest, int dstart, int dend) 
        {
            String input = dest.toString().substring(0, dstart) + source.
                    subSequence(start, end) + dest.toString().substring(dend);
            StringBuffer output = new StringBuffer();
            List<Entry<Character, Boolean>> correction = Learn.this.
                learn_manager.getLetters(input);

            Log.d(TAG, "afterTextChanged: input size (" + input.length() + 
                    ")");

            System.out.println(input);

            for (int i = dstart; i < dstart + end; i++)
            {                    
                if (correction.get(i).getValue())
                {
                    output.append(this.good_letter.replace('$', correction.
                            get(i).getKey()));
                } else {

                    output.append(this.bad_letter.replace('$', correction.
                            get(i).getKey()));
                }
            }

            return Html.fromHtml(output.toString());
        } 
};

这篇关于国信选择未出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆